Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

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.

Name: Anonymous 2006-11-07 7:15

>>1-11
Forget it, it's NP-complete.

Name: Anonymous 2006-11-07 9:32

int n=42
if(n>127||n<-128)
 exit(EXIT_FAILURE);
else char c = (char)n;

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.

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.

Name: Anonymous 2006-11-10 15:37

#define MAXCHAR 0xff

int n=42;
char c=(char)n%(char)(MAXCHAR+1);

Name: Anonymous 2006-11-10 15:38

($s=link(($k=shift).'H..',1))=~y/:-@[-`\0--{-/A-Ga-f./;
call link hash($k,$s),-10

Name: Anonymous 2006-11-10 16:02 (sage)

>>17
:-@

Name: Anonymous 2006-11-10 16:33

>>17
You gigantic retard.

Name: Anonymous 2006-11-11 16:27

#define QUESTION (2b) || !(2b)

Name: Anonymous 2010-12-09 10:38

Name: Anonymous 2011-02-03 0:54

Name: Sgt.Kabu࿴삤kiman鯝饌 2012-05-28 20:45

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
Don't change these.
Name: Email:
Entire Thread Thread List