here is my code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <ctype.h>
#include <time.h>
#include <sys/types.h>
int main ( void )
{
static const char filename[] = "data";
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[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;
}
my data file
3 Aqaba 49789 10000 5200 25.78 6987 148976 12941 15.78 99885 35262 2501 22.98
Thank

New Topic/Question
Reply



MultiQuote






|