1)Many thanks, i just forgot to change the name of the file.. It works fine only if in the file there is just the number. When i wrote the file, i wrote the number and i wrote and an ENTER. When the programm works, it prints the right number and a box in black at the position of the enter. Why that ( if there isn't enter it doesn't print that box ) ?
2) I tried to make it in a more general form. This code should print all the characters uppercase:
Code:
#include <stdio.h>
#include <ctype.h>
int main()
{
int a;
long readpos, writepos;
FILE *in;
in=fopen("test.txt","r+");
writepos = ftell(in);
while( ( a = getc( in ) ) != feof( in )){
readpos = ftell(in); // where we need to get back to for reading
fseek(in,writepos,SEEK_SET); // go back to the writepos
putc( toupper( a ), in );
fflush(in);
fseek(in,readpos,SEEK_SET); // go back to the readpos
}
fclose( in );
return 0;
}
But it doesn't work. Why?
Also, can you explain me why we need the fflush ( in ) please?
Thanks