Be clear about your requirement:
1)How many fileds each line will contain.
2)How many lines the file will contain.
3)What all operations you will do after reading data from file
After getting these things clear u can design your code.
still if u need to read each field den
1)get lines by fgets()
2)after getting the like use strtok(line,",") to get each fields.
And also you should have to read,
1. Homework policy
2. How to post source code?
Show your work first. Do not forget to use code tags. Source code must be surrounded with code tags.
For example,
1)How many fileds each line will contain.
2)How many lines the file will contain.
3)What all operations you will do after reading data from file
1-i dont know , just user know , but i know that s it beetwen 0-50
2- i dont know too , 0-50
all of my problem is here , that i can split one line by strtok function ,but when i have many lines i cant do this .
,rest is a very smiple , i konw .
i wrote this code but ...
static const char filename[] = "data.txt";
FILE *file = fopen ( filename, "r" );
int i = 0,j=0,num[50]={0},rownum=0;
char arra[50][50];
char line[50]; /* or other suitable maximum line size */
char seps[] = ",",*cha;
char *token;
char strArr[40][40],data[50][50];
/*
.read datas from file
.
/*
for(i=0;i<rownum;i++){
token = strtok(arra[i], seps);
while (token)
{
strcpy(strArr[i], token);
token = strtok(NULL, seps);
i++;
}
for(j=0;j<num[i];j++)
data[i][j]=strArr[j];
}