C Programming - Input / Output - Discussion
Discussion Forum : Input / Output - General Questions (Q.No. 1)
1.
In a file contains the line "I am a boy\r\n" then on reading this line into the array str using fgets(). What will str contain?
Answer: Option
Explanation:
Declaration: char *fgets(char *s, int n, FILE *stream);
fgets reads characters from stream into the string s. It stops when it reads either n - 1 characters or a newline character, whichever comes first.
Therefore, the string str contain "I am a boy\n\0"
Discussion:
57 comments Page 6 of 6.
Nikita said:
1 decade ago
Why in ans there is '\0'.
Mahesh said:
1 decade ago
Why \0 is added at last?
Rahul said:
1 decade ago
Why is this \0 printed?
Varsha said:
1 decade ago
@Sundar
Thank you.
Thank you.
Shambavi said:
5 years ago
Thank You @Aravind.
(1)
Deepa said:
1 decade ago
Why \n is printed?
Jayesh rathod said:
4 years ago
Thanks @Kamal.
(2)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers