Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what are the differences between scanf() and fscanf()?

Tags:

c

what are the differences between scanf() and fscanf()?

thanks

like image 455
phpNewComer Avatar asked Apr 04 '11 02:04

phpNewComer


People also ask

What is the difference between fscanf and scanf?

scanf reads from the standard input stream stdin. fscanf reads from the named input stream. sscanf reads from the character string s. Each function reads characters, interprets them according to a format, and stores the results in its arguments.

How scanf () is different from fscanf () and printf () from fprintf ()?

printf () function writes formatted data to screen. sprinf () function writes formatted output to string. scanf () function reads formatted data from keyboard. sscanf () function Reads formatted input from a string.

Which statement is true for fscanf () and scanf ()?

1 Answer. Explanation: The fscanf() is similar to the scanf() function, except that the first argument of fscanf() specifies a stream from which to read whereas scanf() can read from standard input.


1 Answers

scanf() is exactly identical to fscanf() with stdin as the first argument.

like image 188
caf Avatar answered Nov 03 '22 00:11

caf