read/write to file

The Friend amigo at milton.u.washington.edu
Mon Dec 3 15:48:46 AEST 1990



s




     I'm looking for examples on how to create files - putting sequential data
in them, this includes a string and a integer. Specifically its
a name and age list. What I've brewed up so far hasn't
been the greatest of success, so I'm looking for better ways to go about it.

     First round for me using files, so this explains my problem..

     So I have 10 names & ages down in two arrays:
     
     static char names[10][]={........};
     static int ages[10][]={.........};

     Given I define pointes and the like:
     FILE *fp    
     fp=fopen("test_file","w+"); /* w+ so it reads later on, using rewind()
                                                       or some such */

     Next I have a loop set up to dump the array to the file, but
     thats where it gets complicated:
     
     fprintf(fp,"%s%d", names[10][], ages[10][]);



More information about the Comp.lang.c mailing list