I know this is a stupid question but i am quite new to C. How do I convert Integers to Array of Char???
I know how to convert from an Array of Chars using the sscan
Printable View
I know this is a stupid question but i am quite new to C. How do I convert Integers to Array of Char???
I know how to convert from an Array of Chars using the sscan
You can use sprintf...
Code:int a;
char text[255];
sprintf( text, "%d", a );
Also, you can look up a function called "itoa".
[Edited by VirtuallyVB on 04-25-2000 at 09:00 PM]
you should try an explicit conversion, the reason for this over atoi or itoa is that you can use it on allmost every possible variable. how it works:
that shouldn't be too tough...Code:int y;
CString z;
y = 4;
z = "2";
if (blnItoA == TRUE)
{
z = (CString) y;
// Now z == "4"
}
else
{
y = (int) z;
// Now y == 2
}
[Edited by Doomstar on 05-06-2000 at 01:35 PM]
[Edited by Doomstar on 05-06-2000 at 01:36 PM]
I'm sorry, I know some people hate it when people ask questions half way through a thread, but what's the difference between (int) and static_cast<int> ?
In the C++ book I've got it says you should use the latter in C++, but doesn't really give a reason.
eh, well, i don't know the difference. in fact, i've never heard of static_cast<int>, but i'm not doing this for that long either. just use the (int) method, that way you're sure it works (i use it all the time in VC++)