
conversion int to char, char to int ?????
Quote:
> A simple atoi did the trick.
> I could have sworn I tried that. Oh well, at least I'm off that problem.
> Thanks,
> Tim.
> > Could someone please help me with this simple comparison exercise ???
> > I am reading in a char using
> > result = scanf("%s",y);
If y is declared as char*, this will read it in as a string, with no
check for
overflow.
If y is a char, you need scanf("%c", &y) or y=getchar();.
In either case, result will be set to the number of characters read;
this is unlikely to be what you want, judging purely from the name
of the variable.
Quote:
> > "y" will always be a number but I had trouble reading input as an int so
> > I am using the scanf.
This suggests serious confusion. Please post a minimal example of what
you are trying to do.
Quote:
> > I then have an int "x" that I need to do a comparison with "y".
> > I know I am overlooking something.
You can't (directly) compare int's with char*'s in any sensible way/
Quote:
> > What is the best way to do this comparison ?
> > Thanks in advance,
> > Tim.
--
Trevor Walker, Emtex Ltd.
70 St Albans Rd., Watford, Hertfordshire, UK
Tel +44 (0)1923 242420