hi,
i wrote a small function that expects a double and gives back
a char pointer with the value as char-string.
the first time i use it in my program it works fine, but if i call the
function a second or third time, even if i just cout the results both times,
the results are always the same as the result of the first call.
where is my fault?
thanks,
toby
Code:char *doubletostring(double number) { char numberstring[18]; int i=0; double divisor=100000000000000000; while (i<18) { if (number < divisor) { divisor=divisor/10; numberstring[i]=(int)32; i++; } else { numberstring[i]=(int)(48+(number/divisor)); number=fmod(number,divisor); divisor=divisor/10; i++; } } numberstring[i]='\0'; string cut0s; i=0; while (numberstring[i]==(int)32) { i++; } while (numberstring[i]!='\0') { cut0s += numberstring[i]; i++; } cut0s += '\0'; char *returnchars =(char*)cut0s.c_str(); return returnchars; }