linux c 小程序之一 文件的读写
作者:拉格浪日 标签:编程 | 阅读次数:524 |
![]() ![]() ![]() |
| ![]() ![]() ![]() |
#include
struct student { char name[10]; int age; }; int main() { FILE *fp; char buffer[40]; struct student boya[1]={"ssssd",10}, boyb[1]={"\0",0}, *pp, *qq; pp=boya; qq=boyb; fp=fopen("8-6.txt","w"); fprintf(fp,"%s %d\n",pp->name,pp->age); fclose(fp); fp=fopen("8-6.txt","r"); fscanf(fp,"%s %d",qq->name,&qq->age); fclose(fp); printf("%s-----%d",qq->name,qq->age); return 0; } |