Exercise :: Library Functions - True / False Questions
- Library Functions - General Questions
- Library Functions - Find Output of Program
- Library Functions - Point Out Errors
- Library Functions - True / False Questions
- Library Functions - Yes / No Questions
1. | It is necessary that for the string functions to work safely the strings must be terminated with '\0'. |
|||
Answer: Option A Explanation:
C string is a character sequence stored as a one-dimensional character array and terminated with a null character('\0', called NULL in ASCII).
|
2. | FILE is a structure suitably typedef'd in "stdio.h". |
|||
Answer: Option A Explanation:
FILE - a structure containing the information about a file or text stream needed to perform input or output operations on it, including:
fpos_t - a non-array type capable of uniquely identifying the position of every byte in a file. |
3. | ftell() returns the current position of the pointer in a file stream. |
|||
Answer: Option A Explanation: The ftell() function shall obtain the current value of the file-position indicator for the stream pointed to by stream. Example: |
4. | Data written into a file using fwrite() can be read back using fscanf() |
|||
Answer: Option B Explanation:
fwrite() - Unformatted write in to a file. |
5. | If the two strings are found to be unequal then strcmp returns difference between the first non-matching pair of characters. |
|||
Answer: Option A Explanation: g = strcmp(s1, s2); returns 0 when the strings are equal, a negative integer when s1 is less than s2, or a positive integer if s1 is greater than s2, that strcmp() not only returns -1, 0 and +1, but also other negative or positive values(returns difference between the first non-matching pair of characters between s1 and s2). A possible implementation for strcmp() in "The Standard C Library". |