C examples for File:Binary File
Reading Data from a file
#include <stdio.h> int main() /*from w w w .ja v a 2 s. c o m*/ { FILE *pRead; char name[10]; pRead = fopen("names.dat", "r"); if ( pRead == NULL ) printf("\nFile cannot be opened\n"); else printf("\nContents of names.dat\n\n"); fscanf(pRead, "%s", name); while ( !feof(pRead) ) { printf("%s\n", name); fscanf(pRead, "%s", name); } }