首页 | 手机版 | 三国演义 | 三国志 | 史将 | 背景 | 藏书阁
首页 -> 精彩文章 -> linux c 小程序之一 文件的读写

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;
}


浙ICP备06020153号-1