Re: error correcting
"Default User" <defaultuserbr@yahoo.com> wrote in message
news:59s3sjF2l4tooU1@mid.individual.net...
Jim Langston wrote:
"i" <imhskalatis@yahoo.co.in> wrote in message
news:1178085831.240309.245870@h2g2000hsg.googlegroups.com...
ch=getche();
warning C4244: '=' : conversion from 'int' to 'char', possible loss
of data Okay, that one is livable. I don't know why it returns an
int when it doesn't return an error code (no -1 or anything I can
see). int ch; may be better but shrug
Presumably (it's a non-standard function) it is similar to getchar() or
other similar ones. That means it can return EOF, which is a negative
integer.
Yes, since this was a windows program, and since I use MS VC++ .net 2003 I
actually read the MSDN page on the call. Nothing in the documentation on
the call suggests it could return anything other than a character.
One thing I didn't think of, though, is for DBCS (Double Byte Character
Sets) where one character may not necessarily fit in one byte. So, if this
code is using getche instead of getch, then it is being designed for
multilingual, so this is actually an error, trying to fit a wide character
into a single byte won't fit.
You have a function calling main, which is a no-no for many reasons.
The principle one being that it's illegal in C++.