Read File Data
eharetea

Using fscanf() to read characters from a file into a multi-dimensional character array.

Read files in C.

Date Created:Thursday May 17th, 2007 04:21 PM
Date Modified:Sunday August 03rd, 2008 12:50 PM


/*
* Author: Dan Lynch
*/

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

int main() {
    FILE infile;
    char name[5][20];
    int i=0;
    int j;

    infile fopen("data.c","r");
    
    while ( (fscanfinfile"%s"name[i++] )) != EOF ) ;

    for ( j=0j<ij++) {    
        printf("%s\n",name[j]);
    }

    return 0;
}



Downloads:
Download: test.c 334 B

Please login or Click Here to register for downloads
Creative Commons License
Read File Data by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com