The function prototypes forscanf() andfscanf()are as follows:
int scan( const char* format , ... );
int fscanf( FILE* stream , const char* format , ... );
Again, spaces have been added to emphasize the common parts of each function.
For the console input, we can use scanf() and fscanf() interchangeably. These two function calls are equivalent, as follows:
scanf( "%d" , &anInteger );
fscanf( stdin, "%d" , &anInteger );
Whitespace has been added to emphasize where the functions differ. The scanf(…) function is shorthand for fscanf( stdin , … ) when input is received from the console. One major difference between scanf() and printf() is that we must pass the address of the variable to be assigned or a pointer to the variable we wish to give a value to the function. Recall that in C, function parameter values are passed by a copy. So, with...