Mail Archives: djgpp/2001/10/19/15:33:50
"Bart van den Burg" <bart AT bart99 DOT tmfweb DOT nl> wrote in
news:9qpp2o$b1t$1 AT cyan DOT nl DOT gxn DOT net:
> the program gives me no compilation errors at all (compliled with
> -Wall) I could be wrong here but:
> you have "(int)variable" which is the same as "int(variable), so
> "(char)variable" is similar to "char(variable)"?
no that is so fundamentally wrong, i do not know how to begin.
(int) variable
means cast the variable to int no matter what it was before.
on the other hand, int(x), and this only exists in C++, AFAIK, means create
a new integer with the initial value x.
in this case, you are not trying to intialize a new char out of x, but jsut
use the value of x.
> sprintf(buffer, "%c", char(x));
you definitely should use snprintf, however, instead of sprintf.
or better yet, use a C++ solution if you are working in C++.
Sinan.
--
--------------------------------
A. Sinan Unur
http://www.unur.com/
- Raw text -