i am pretty new to c programming, i have been playing with writing to files, just for messing around, i wrote a program to write 3 "points" to a file. everything works, except for the number 10, when it writes the number 10, it writes 0D 0A, instead of just 0A, it then screws up the read order or something too.
Code:
#include <stdio.h>
void main()
{
int counter = 0;
FILE *filevariable;
int temp;
filevariable = fopen("testfile", "w");
printf("enter x ; y ; z \n");
printf("[[max is signed 32 bit]]\n");
//have the user type "exit" to leave
while(temp != 1)
{
counter++;
fseek(filevariable,12*counter-8,SEEK_SET);
printf(" POINT # %d\n", counter);
scanf("%d", &temp);
if(temp == 10) printf("10 entered");
fwrite(&temp, 4, 1, filevariable);
scanf("%d", &temp);
fwrite(&temp, 4, 1, filevariable);
scanf("%d", &temp);
fwrite(&temp, 4, 1, filevariable);
printf("\n\n");
temp = counter*3;
fseek(filevariable,0,SEEK_SET);
fwrite(&temp, 4, 1, filevariable);
printf("points saved!\n\n");
}
fclose(filevariable);
}