rosynirvana 发表于 2014-4-12 20:43 非常感谢 加了一层括号就好了 |
//学生信息管理系统┌ └ ┐ ┘ ─ │ ├ ┤ ┬ ┴ ┼ //分五大模块:档案录入 档案修改 档案删除 查看学生信息 统计总数 #include <stdio.h> #include <stdlib.h> #include "show.h" unsigned long int getfilelen(char filename[]); struct inf { char name[10]; //姓名 char age; //年龄 char sex[2]; //性别 char father[10]; //父亲姓名 char mather[10]; //乡亲姓名 char lastschool[20]; //毕业学校 char homeaddress[50]; //家庭住址 char phone[20]; //联系电话 char others[100]; //备注 }; int main() { unsigned int choosing; struct inf *head; while(1) { system("cls"); show("学生信息管理系统","请输入相应选项编号,按回车"); printf("┌───────────────────────────┐\n"); printf("│\t\t\t\t\t\t\t│\n"); printf("│\t\t\t\t\t\t\t│\n"); printf("│\t\t\t1.档案录入\t\t\t│\n"); printf("│\t\t\t2.档案修改\t\t\t│\n"); printf("│\t\t\t3.档案删除\t\t\t│\n"); printf("│\t\t\t4.查看信息\t\t\t│\n"); printf("│\t\t\t5.统计总数\t\t\t│\n"); printf("│\t\t\t0.退出系统\t\t\t│\n"); printf("│\t\t\t\t\t\t\t│\n"); printf("│\t\t\t\t\t\t\t│\n"); printf("│\t\t\t\t\t\t\t│\n"); printf("└───────────────────────────┘\n"); printf("请输入选项:"); scanf("%d",&choosing); printf("%d",sizeof(struct inf)); switch(choosing) { case 0: return 0; case 1: printf("%ld",getfilelen("d:\\123.txt")); break; case 2: break; case 3: break; case 4: break; case 5: break; } system("pause"); } } struct inf* creatlist(unsigned int n,unsigned int size) { struct inf *p; p=(struct inf*)calloc(n,size); } unsigned long int getfilelen(char filename[]) { FILE *fp; unsigned long fl; if (fp=fopen(filename,"rb+")==NULL) printf("打开文件失败!"); system("pause"); printf("%d",fseek(fp,1L,0)); //移动文件指针 system("pause"); fl=ftell(fp); system("pause"); fclose(fp); return fl; } int getfiledata(char filename[],struct inf *p,int size,int n) { FILE *fp; fp=fopen(filename,"rb"); fread(p,size,n,fp); fclose(fp); } |
贴完整的代码 |
if (fp=fopen(filename,"rb+")==NULL) 问题在这一句, ==的优先级比=要高 |