hi....i am writing a code which reads the contents of file....it has first name, lastname and phone number.....now i want ot read all the first names into one array second into another and phone numbers into third array....i tried but i could read only line by line.....please help out...my code is here
thanx in advance

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

int main()
 char c[50];
 FILE *file;

 file = fopen("in.txt", "r");

 if(file==NULL) {
   printf("Error: can't open file.\n");

   return 1;
   printf("File opened successfully. Contents:\n\n");

   while(fgets(c, 50, file)!=NULL)

    printf("String: %s", c);


   printf("\n\nNow closing file...\n");
   return 0;

but i need an out put like this...
array1=list of first names
array2=list of last names
array3=list of phone numbers

if the first name, last name, phone number are space-separated, then read this to learn how to parse the line


If the first name second name and phone number are consistently in this order throughout the file then an ifstream read object in a while loop may work;