My question is very simple. I have a file of ascii or binary , whatever. Now, I want every byte in the file to be 0x4f, how can I do it in C ? The question is so simple, but suprisingly, there is no answer on the Internet. I have a sample code, however, there is a dead loop when I run the program:
#include <stdio.h>
int main ()
{
    FILE * pFile;
    pFile = fopen ("write_file_2","wb");
    unsigned char c = 0x4f;
    while(1){
        if( feof(pFile) )
            break;
        int res = fputc(c, pFile);
        printf("%d\n", res);
    }
    fclose (pFile);
    return 0;
}
I wonder why the feof() takes no effect. Thanks!
 
     
     
     
    