Custom data types
typedef struct student record;
Structure Body Array
Record rs[10000] = {0};
void Spit (int max);
Reading files
int main ()
{
int length,i,j,k;//per line data length \ structure subscript \ member variable number \ Loop variable
Char clinestr[255],cdata[80],ctmp[2];//per line file content \ read from file member variable content \ value of single character per row of data
Reading data from one line in a file into an array of structures
while ((!feof (FP)) && ((Fgets (CLINESTR,MAXLINE,FP))!= NULL)
{
Length = strlen (CLINESTR);
for (k = 0; k < length; k++)
{
memset (cTmp, 0, sizeof (CTMP));
memcpy (CTMP, &clinestr[k],1);
Separated by commas among the members of the file
if (ctmp[0]!= ' \ n ')
{
strcat (CDATA,CTMP);
}
Place the contents of the member variable read from the file into the data file record structure body array
Else
{
if (j = = 0)
{
strcpy (Rs[i].stuname,cdata);
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.