int vs char: please help me

int vs char: please help me

Post by shant » Tue, 29 May 2007 15:46:45


hi,

thanks for spending your time with my problem. my problem is
"i have a program which has lot of operations to perform with
integers: program asks to give some int type inputs. if the inputs are
really int my program is behaving properly. but if a char is given as
input insted of int myprogram behaving unevenly". now i want the
following thing
1) my program has to say that the input (char instead of int) is
illegal when the char has been given as input to my program.
2) progam has to exit in case of illegal entry.

thanks all,
regards,
prasanth thandra.
 
 
 

int vs char: please help me

Post by James Denn » Tue, 29 May 2007 15:57:48


You're asking in the wrong group; comp.std.c is for
discussion of the C standard, not for questions about
how to write programs in C.

alt.comp.lang.learn.c-c++ might be a better group for
your question, though I'd suggest trying to be clearer
about what you mean: all input is in the form of chars,
so maybe your question is about what happens if the
chars that are entered are not digits, or are otherwise
not a valid int value. Taking some time to try to
express your question clearly can make it a lot easier
for people to help you. I'd also suggest that before
posting (to alt.comp.lang.learn.c-c++ or elsewhere)
that you find the FAQ for that group and read it; it
will give you information on how to ask questions.

-- James

 
 
 

int vs char: please help me

Post by Richard He » Tue, 29 May 2007 16:06:23

shanti said:


I think I understand your problem, but I'm not certain. If I have
guessed correctly, your user is typing BUTTERFLY instead of 6, and
HATSTAND instead of 42, and you want to be able to detect this and
terminate the program if it happens.

If that is your problem, we can easily help you to improve the input
method you are using. But to do that, we need to see /which/ input
method you are using. So please post the smallest complete, compilable
program that demonstrates the problem you are having, and we'll help
you to sort it out.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.yqcomputer.com/
email: rjh at the above domain, - www.
 
 
 

int vs char: please help me

Post by jacob navi » Tue, 29 May 2007 18:49:02


Do your own homework shanti, do not try to cheat.