| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 326 人关注过本帖
标题:初学者求教怎么改
只看楼主 加入收藏
zedongzzd
Rank: 1
来 自:江苏昆山
等 级:新手上路
帖 子:2
专家分:3
注 册:2011-4-17
收藏
 问题点数:0 回复次数:0 
初学者求教怎么改
#include<stdio.h>
#include <string.h>
#include<malloc.h>
#include<stdlib.h>
struct zhigong
{
  unsigned number;
  char name[15];
  char sex;
  int age[2];
  char xueli;
  int gongzi[6];
  char dizhi[100];
  int phone[15];
  struct zhigong *next;
 };

struct zhigong *adds()
{ struct zhigong *yuangong=(struct zhigong *)malloc(sizeof(struct zhigong));
  if(yuangong!=NULL)
  {   printf("Please input the number:");
      scanf("%d",&yuangong->number);
      printf("Please input the name:");
      scanf("%s",&yuangong->name);
      printf("Please input the sex(M or W):");
      scanf("%s",&yuangong->sex);
      printf("Please input the age:");
      scanf("%s",&yuangong->age);
      printf("Please input a degree(zhongzhuan(Z)dazhuan(D)benke(B)shushi(S)poshi(P):");
      scanf("%s",&yuangong->xueli);
      printf("Please input the wage:");
      scanf("%d",&yuangong->gongzi);
      printf("Please input the address:");
      scanf("%s",&yuangong->dizhi);
      printf("Please input the phone:");
      scanf("%d",&yuangong->phone);
      yuangong->next=NULL;
   }
     return(yuangong);
}


void add(struct zhigong **yuangong)
{   struct zhigong*yuangongs=adds();
    if(yuangongs!= NULL)
    {
        if((*yuangong)!=NULL)
        {
            yuangongs->next=(*yuangong);
        }
        (*yuangong)=yuangongs;
    }
}

struct zhigong *yuangong()
{return NULL;
}


void save(struct zhigong*yuangong)

 {unsigned char filename[13];
 printf("Please input the filename:");
 scanf("%s",filename);
 FILE *filesave;               /*错误点1*//*错误点2*/
 if((filesave=fopen("filename", "wb"))==NULL)    /*错误点3*/
     {
      printf("Cannot open file %s!\n", filename);
      return;
     }
  puts("Saveing ...");
  yuangong=yuangong->next;
  while(yuangong)
  {
        fwrite(yuangong,sizeof(struct zhigong),1,filesave);
        yuangong=yuangong->next;
  }
  fclose(filesave);
  puts("Saveing is finished!");
}
void load(struct zhigong *yuangong)
{char filename[13];
  printf("Please input the filename:");
  scanf("%s",filename);
  FILE *fileload;                                      /*错误点4*//*错误点5*/
  if((fileload=fopen("filename","rb"))==NULL)                          /*错误点6*/
 {printf("Cannot open file %s !\n", filename);
  return;}
  while(!feof(fileload))
  {
  fread(&yuangong,sizeof(struct),1,fileload);
  yuangong=yuangong->next;
  }
  fclose(fileload);
  return;
}

void main()
{char key;
 int num;
 char tiaojian;
 help();
 struct zhigong *yuangong;
 create();
 printf("\n=");
 while((key=getchar())!='q'&&'Q'&&key!=27)
 {switch(key)
  {case'a':case'A':add(&yuangong);printf("Input success\n");getchar();break;
   case'e':case'E':save(yuangong);getchar();break;
   case'r':case'R':load(yuangong);getchar();break;
   default: puts("Error command!");
   }
}
 getch();
}

编译环境:wintc     真心求教高手  

错误1: typedef 符号使用不当在 save 函数中

错误2: 未定义的符号'filesave'在 save 函数中

错误3: typedef 符号使用不当在 load 函数中

错误4: 未定义的符号'fileload'在 load 函数中

错误5: 指针必需在 -> 的左侧在 load 函数中

错误6: 构造或联合语法错误在 load 函数中

错误7: 表达式语法错在 main 函数中

搜索更多相关主题的帖子: yuangong include number 
2011-06-29 18:30
快速回复:初学者求教怎么改
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028276 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved