change int into char
Name:
Anonymous
2006-11-05 20:38
I'm programming in C++, how do I change an int into a character that has the same numeric value?
Name:
Anonymous
2006-11-05 20:39
(sage)
FAIL FOR STUPID
Name:
Anonymous
2006-11-05 21:44
int i;
char j;
char buf[4];
sprintf(buf, "%d", i);
sscanf(buf, "%d", &j)
Simple!
Name:
Anonymous
2006-11-05 21:52
(char)integer
Name:
Anonymous
2006-11-05 23:22
>>1
why would you want to? use strings instead.
Name:
Anonymous
2006-11-06 2:34
program on an 8-bit platform, ints and chars are the same there.
Name:
Anonymous
2006-11-06 5:40
>>3
That's C not C++ you cockmongling grinmaster
Name:
Anonymous
2006-11-06 6:44
ostringstream oss << number;
string s = oss.str();
Name:
Anonymous
2006-11-06 6:45
>>1
int n = 65;
char c = (char)n;
Name:
Anonymous
2006-11-06 12:49
delete from sl_journal where batch = 'SJ2352'
Name:
Anonymous
2006-11-07 6:47
>>1
Simple, you don't
You just assign the integer to the character, and pray that it's not below -128 or above 127.
Newer Posts