A
abdur_rab7
Though the uninitialised pointer leeds to error,
The code
char *file_name = "t1.txt";
is legal
Always try to check the file opening cause
the code
FILE *pf = fopen(file_name, "r+");
"r+" -- to open an existing text file for reading and writing
if the file does not exists, it will give a null pointer.
If the file does not exists and u try to execute do fputs with null
pointer will cause undefined behaviour
Best Regards,
Abdur
The code
char *file_name = "t1.txt";
is legal
Always try to check the file opening cause
the code
FILE *pf = fopen(file_name, "r+");
"r+" -- to open an existing text file for reading and writing
if the file does not exists, it will give a null pointer.
If the file does not exists and u try to execute do fputs with null
pointer will cause undefined behaviour
Best Regards,
Abdur