I have this code, but it doesn't work. It should read a number from a file and print it back, in the same file, multiplied by ten.
Can you help me find the error?Code:#include <stdio.h> int main() { int num; FILE *in; in=fopen("test.txt","r+"); fscanf( in, "%d", &num ); fprintf( in, "%d", num * 10 ); fclose( in ); return 0; }
Also, if a program that reads charcter by character from a file, prints back that character changed in the same file, will the next characters of the file be lost.? For example a file contains 10 characters. You read the first one, you change it, and you print it back in the same file( and you want to procceed in the nect character ). The next 9 characters of the file will be lost?
Thanks



LinkBack URL
About LinkBacks


