char inputString[100] = {0};
To get string
input from the keyboard which one of the following is better?
1) gets(inputString)
2) fgets(inputString,
sizeof(inputString), fp)
Answer
& Explanation:
The second one
is better because gets(inputString) doesn't know the size of the string passed
and so, if a very big input (here, more than 100 chars) the charactes will be
written past the input string. When fgets is used with stdin performs the same
operation as gets but is safe.
No comments:
Post a Comment