Hi everyone,
I have a program which takes the reading from a text box and saves it to a text file using the following code:
...it seems to work OK when I put non-integers into buf, but when buf = an integer, the text file doesn't just have the number stored in it - it has this instead (for example when I put '3' into buf):Code:fopen_s(&pFile,"textfile.txt","w"); fwrite (buf , 1 , sizeof(buf) , pFile ); //pFile and buf have been declared earlier (buf is the variable storing the user's unput to the text box). fclose (pFile);
3
Why does it add that strange character on the end, and how can I stop it from doing that? Failing that, is there a way to always add a decimal point to a certain number of decimal places onto the end?
Thanks.



1Likes
LinkBack URL
About LinkBacks


