Which inbuilt function in C is used to read string from system console?
2021
Which inbuilt function in C is used to read string from system console?
- A.
puts ()
- B.
cgets ()
- C.
getche ()
- D.
getchar ()
Attempted by 1603 students.
Show answer & explanation
Correct answer: B
Correct Answer: cgets()
The correct inbuilt function in C used to read a string from the system console is cgets(). This function is specifically designed to read a line of text from the standard input and store it in a character array.
Analysis of Options
puts(): This function is used to write or print a string to the console. It outputs data, it does not read input.
cgets(): This function reads a string from the console. It is a non-standard function but is commonly used in older C compilers for safe string input.
getche(): This function reads a single character from the keyboard and echoes it immediately. It does not read a full string.
getchar(): This function reads a single character from the standard input stream. It returns the character as an integer and does not handle strings.
Therefore, among the given options, cgets() is the only function specifically intended for reading a string from the system console.