I am facing a weird problem when i try to write the contents of a char array into a file.
I first do:
Code:
fp=fopen(filename,"w");
fprintf( fp1 ,"%s" , buf);
fclose(fp);
here, buf points to the starting location of my char array...
the contents of this array will be re-written during the execution , and so, to transfer the new content into a file I do :
Code:
fp=fopen(filename,"a");
fprintf( fp1 ,"%s",buf);
fclose(fp);
again , here buf points to the start ...
the problem is : after the execution , when i open the file with "cat" , the contents of the file is displayed correctly..
when i open it thru a text editor, I see non-ascii characters at the end of each line