Hello everybody,
I guess this question has been asked before, but I couldn't find it...
I need to write the function IntToStr, I can't use itoa, and I'm stuck. Could you please help me?
thanks
Maga
Hello everybody,
I guess this question has been asked before, but I couldn't find it...
I need to write the function IntToStr, I can't use itoa, and I'm stuck. Could you please help me?
thanks
Maga
Use sprintf perhaps?
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
I think he's supposed to implement his own version.
See if you can find a way to generalize this and use it in yoru IntToStr function.Code:char str[4] int i=213; str[0]=i/100+'0'; i%=100; str[1]=i/10+'0'; i%=10; str[2]=i+'0'; str[3]='\0';
edit: Fixed typo. Thanks, vart.
Last edited by NeonBlack; 03-24-2010 at 06:52 PM.
I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo
at least make it of correct typechar* str[4]
and of cause it should be a little longer...Code:char str[4];
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler