I'm not a C guy by any means, but I think you can cast it.... such as:
newvar = (int)x + (int)y;
Someone who Codes a lot of C, please check this over...
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
For a value 0-9, you can just add '0' to get the corresponding digit character.
#include <stdio.h>
int main(void)
{
char text[] = "StringX";
int digit;
for (digit = 0; digit < 10; ++digit)
{
text[6] = digit + '0';
puts(text);
}
return 0;
}
/* my output
String0
String1
String2
String3
String4
String5
String6
String7
String8
String9
*/
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
In case you didn't notice, the fellow wanted the code in C.
WolfPack
Postaholic
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
> In case you didn't notice, the fellow wanted the code in C.
He also wanted it 3 YEARS ago as well.
Not only late, and in the wrong language, it's also old C++, and non-portable.
Use '0', not 48 (like was used oh so long ago in a galaxy far far away).
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953