求大神用C语言把上面的读入一链表,
不要用微软的 DOM, MSXML4的。
struct account
{
int AccountNO;
char password[5];
int balance;
char name[20];
char ID[20];
char sex[6];
char address[20];
int freeze;
struct account *next;
};
不知道为什么这个password[5]这个数组,当读入balance不是0的时候,会变化。
void main()
{FILE *fp;int n=0;
char nige[5]="asdfg";
char s[]="account.xml",t;
char a1[]="</AccountList>",a2[]="</AccountList>";
struct account *p1,*p2,*head;
if((fp=fopen(s,"r+"))==NULL)
{printf("the file non-existent");
exit(0);}else{fseek(fp,24L,0);
p1=p2=(struct account *)malloc(LEN);
fscanf(fp,"%6d,",&p1->AccountNO);
fscanf(fp,"%[^,]s,",&p1->password);
fscanf(fp,",%d",&p1->balance);
fscanf(fp,",%[a-z]s",&p1->name);
fscanf(fp,",%[^,]s",&p1->ID);
fscanf(fp,",%[^,]s",&p1->sex);
fscanf(fp,",%[^,]s",&p1->address);
fscanf(fp,",%d",&p1->freeze);head=NULL;
printf("%d,",p1->AccountNO);
printf("%s,",p1->password);
printf("%d,",p1->balance);
printf("%s,",p1->name);
printf("%s,",p1->ID);
printf("%s,",p1->sex);
printf("%s,",p1->address);
printf("%d\n",p1->freeze);
}
<AccountList><account>000001,asdfg,500,mai,1234567890123456798,mam,guanzghou,1</account><account>000002,asdfg,10,mai,1234567890123456789,man,guanzghou,1</account><account>000003,asdfg,10,mai,1234567890123456789,man,guangzhou,1</account></AccountList>