Is there a way to get the ANSI value of a digi?
IE 0 = 48 1 = 49 and so forth.
I'm currently just coding my own with a bunch of If statements but would be nice to know of a pre built
Is there a way to get the ANSI value of a digi?
IE 0 = 48 1 = 49 and so forth.
I'm currently just coding my own with a bunch of If statements but would be nice to know of a pre built
int n = 5;
char c = n + '0';
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
erm thats does not work. if that was case then char 0 = 0 + 0 ...
i just used a function
Code:int ansival(int x) { if (x==0) { return 48; } if (x==1} { return 49; } if (x==2) { return 50; } if (x==3) { return 51; } if (x==4) { return 52; } if (x==5) { return 53; } if (x==6) { return 54; } if (x==7) { return 55; } if (x==8) { return 56; } if (x==9) { return 57; } }
You forgot the single quotes around the 0. '0' returns the ASCII value of 0. So n + '0' is the ASCII value of a number.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
You didn't read it close enough. He said '0' not 0. '0' is the character 0, not the number 0. If you convert '0' to an integer you get 48. The formula he gave you is correct.
EDIT: Touche, beaten by 0 minutes. If I just pressed the "post reply" button instead of taking an extra breath...
Last edited by Magos; 05-24-2003 at 05:25 PM.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Heh. When I clicked on the 'Post Reply' button, yours was there, and I thought it screwed up.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
*hangs head in shame* thanks a lot hehe, saves a lot of overhead in the long run