fwrite and decimal points
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:
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);
...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):
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.