home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sams Teach Yourself C in 21 Days (6th Edition)
/
STYC216E.ISO
/
mac
/
Examples
/
Day16
/
fscanf.c
< prev
next >
Wrap
C/C++ Source or Header
|
2002-08-11
|
484b
|
24 lines
/* Reading formatted file data with fscanf(). */
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
float f1, f2, f3, f4, f5;
FILE *fp;
if ( (fp = fopen("INPUT.TXT", "r")) == NULL)
{
fprintf(stderr, "Error opening file.\n");
exit(1);
}
fscanf(fp, "%f %f %f %f %f", &f1, &f2, &f3, &f4, &f5);
printf("The values are %f, %f, %f, %f, and %f\n.",
f1, f2, f3, f4, f5);
fclose(fp);
return 0;
}