#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
struct bank{
int id;
char name[30];
double money;
};
int main(){
struct bank *p,*q;
p=(struct bank*)malloc(sizeof(struct bank));
q=(struct bank*)malloc(sizeof(struct bank));
FILE *fp;
p->id=20;
p->money=50;
if((fp=fopen("ddh.txt","w+"))==NULL)
{
printf("cuowu");
exit(0);
}
fprintf(fp,"%d,%f",p->id,p->money);
fclose(fp);
fp=fopen("ddh.txt","r");
if(!fp)
{
printf("errror!\n");
exit(-1);
}
fscanf(fp,"%d,%f",&q->id,&q->money);
fclose(fp);
printf("%d,%f",q->id,q->money);
}
#include<stdlib.h>
#include<windows.h>
struct bank{
int id;
char name[30];
double money;
};
int main(){
struct bank *p,*q;
p=(struct bank*)malloc(sizeof(struct bank));
q=(struct bank*)malloc(sizeof(struct bank));
FILE *fp;
p->id=20;
p->money=50;
if((fp=fopen("ddh.txt","w+"))==NULL)
{
printf("cuowu");
exit(0);
}
fprintf(fp,"%d,%f",p->id,p->money);
fclose(fp);
fp=fopen("ddh.txt","r");
if(!fp)
{
printf("errror!\n");
exit(-1);
}
fscanf(fp,"%d,%f",&q->id,&q->money);
fclose(fp);
printf("%d,%f",q->id,q->money);
}