#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
int main ( void )
{
FILE *file = fopen ( "data.txt", "r" );
int i, j;
char arra[128][128];
char line[128]; /* or other suitable maximum line size */
for(i=0; i<128; i++)
for(j=0; j<128; j++)
arra[i][j] = '\0';
for(i=0; i<128; i++)
line[i] = '\0';
if ( file != NULL )
{
i=0;
while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
{
strcpy(arra[i], line);
printf("array ----> %s ", &arra[i]);
i++;
}
fclose ( file );
}
else
{
perror ( filename ); /* why didn't the file open? */
}
return 0;
}