undefined behaviour?

  • Thread starter Friedrich Dominicus
  • Start date
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Working with files 1
I'm facing a run-time error 14
[re-post] why no output 11
No. of 'a' in a text file 77
SEGFAULT problem 5
simple file compression program 8
Program not giving any output 33
File Handling (Newbie) 9

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,474
Latest member
AntoniaDea

Latest Threads

Top