81.6k views
5 votes
What function do you use to read a specially formatted input from an open file stream?

a) fscanf()
b) fread()
c) gets()
d) scanf()

1 Answer

5 votes

Final answer:

To read formatted input from a file stream, use the fscanf() function, which allows for interpreting data according to a specified format.

Step-by-step explanation:

To read a specially formatted input from an open file stream, the function you would use is fscanf(). This function works similarly to scanf(), but instead of reading the data from standard input, it reads from the specified file pointer. The fscanf() function can read and interpret data of various types according to a formatted input specification. For example, to read integers and strings with specific patterns, you can specify a format string within the fscanf() function. Unlike fscanf(), the fread() function is used for reading a block of data without specific formatting, gets() is used for reading strings from standard input, and scanf() is for reading formatted input from standard input.

User Eugene Cheverda
by
9.0k points