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 5 of 6.
Vivek said:
1 decade ago
Please any one clear exlpain.
I don't understand.
I don't understand.
(1)
Sairamteja said:
1 decade ago
The question is good and \r is a carriage return.
Abhi said:
9 years ago
For me, only I am a boy is getting in a string.
Riya said:
1 decade ago
@Sundar : Thanks for the perfect explanation.
Yami said:
1 decade ago
Sundar : Thanks for the nice explanation.
APARNA said:
9 years ago
Will anyone explain it with an example?
Nutan said:
1 decade ago
@kamal dua
Thanks for explain it.....
Thanks for explain it.....
Isvariyaa said:
1 decade ago
Also gets printed in Turbo C compiler.
Sharmi said:
1 decade ago
Thanks sundar. Nice explanation.
Amaresh said:
2 decades ago
Explain in details the answer.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers