Help on some array problem!!

i have no idea how to make a text file

abc efg
hij klm
nop qrs

to be a array such as, arr[0] to be "abc efg" arr[1] "hij kml" etc..... in C

I found following example on the web and did a minor change to meet your requirement:

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

int main ( void )
{
static const char filename[] = "data.txt";
FILE *file = fopen ( filename, "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[j] = '\0';

for(i=0; i<128; i++)
line = '\0';

if ( file != NULL )
{

i=0;

while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
{

strcpy(arra, line);
i++;

}
fclose ( file );
printf("%s", &arra[1]); /* HERE YOU COULD PRINT ARRAY ELEMENTS, LINE 2 IN THIS CASE */
}
else
{
perror ( filename ); /* why didn't the file open? */
}


return 0;
}

HTH

Your question looks a lot like homework. Please note that we have a special forum for that.

pseudocoder did a commendable job in answering your question.