change int into char
1
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?
2
Name:
Anonymous
2006-11-05 20:39
(sage)
FAIL FOR STUPID
3
Name:
Anonymous
2006-11-05 21:44
int i;
char j;
char buf[4];
sprintf(buf, "%d", i);
sscanf(buf, "%d", &j)
Simple!
4
Name:
Anonymous
2006-11-05 21:52
(char)integer
5
Name:
Anonymous
2006-11-05 23:22
>>1
why would you want to? use strings instead.
6
Name:
Anonymous
2006-11-06 2:34
program on an 8-bit platform, ints and chars are the same there.
7
Name:
Anonymous
2006-11-06 5:40
>>3
That's C not C++ you cockmongling grinmaster
8
Name:
Anonymous
2006-11-06 6:44
ostringstream oss << number;
string s = oss.str();
9
Name:
Anonymous
2006-11-06 6:45
>>1
int n = 65;
char c = (char)n;
10
Name:
Anonymous
2006-11-06 12:49
delete from sl_journal where batch = 'SJ2352'
11
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.
12
Name:
Anonymous
2006-11-07 7:15
>>1-11
Forget it, it's NP-complete.
13
Name:
Anonymous
2006-11-07 9:32
int n=42
if(n>127||n<-128)
exit(EXIT_FAILURE);
else char c = (char)n;
14
Name:
13
2006-11-07 9:40
(sage)
oops, i forgot a ; at on the first line, but you should be able to figure that out.
15
Name:
Anonymous
2006-11-10 14:35
>>1
WHY do you want to do this? I don't think you need it, keep your int.
16
Name:
Anonymous
2006-11-10 15:37
#define MAXCHAR 0xff
int n=42;
char c=(char)n%(char)(MAXCHAR+1);
17
Name:
Anonymous
2006-11-10 15:38
($s=link(($k=shift).'H..',1))=~y/:-@[-`\0--{-/A-Ga-f./;
call link hash($k,$s),-10
18
Name:
Anonymous
2006-11-10 16:02
(sage)
19
Name:
Anonymous
2006-11-10 16:33
>>17
You gigantic retard.
20
Name:
Anonymous
2006-11-11 16:27
#define QUESTION (2b) || !(2b)
22
Name:
Anonymous
2010-12-09 10:38
24
Name:
Anonymous
2011-02-03 0:54
Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
Newer Posts