[Error] student.h: No such file or directory 大神帮忙看一下, 文件的读写
运行后报错[Error] student.h: No such file or directory,请问下是哪里出问题了,不是有student.h吗?main.c
程序代码:
#include<stdio.h> #include"student.h" void getList(Student aStu[],int number); int save(Student aStu[],int number); int main(int argc,char const *argv[]) { int number=0; printf("输入学生数量: "); scanf("%d",&number); Student aStu[number]; getList(aStu,number); if(save(aStu,number)) { printf("保存成功\n"); } else { printf("保存失败\n"); } return 0; } void getList(Student aStu[],int number) { char format(STR_LEN);//字符数组 大小是20 sprintf(format,"%%%ds",STR_LEN-1);//向一个字符串输出 ,s是字 //"%19s" int i; for(i=0;i<number;i++) { printf("第%d个学生: \n",i); printf("\t姓名: "); scanf(format,aStu[i].name); printf("\t性别 (0-男,1-女,2-其他):"); scanf("%d",&aStu[i].gender); printf("\t年龄: "); scanf("%d",&aStu[i].age); } } int save(Student aStu[],int number) { int ret =-1; FILE *fp=fopen("student.date","w"); if(fp) { ret=fwrite(aStu,sizeof(Student),number,fp); fclose(fp); } return ret==number; }
student.h
程序代码:
#ifndef __STUDENT_H__ #define __STUDENT_H__ const int STR_LEN = 20; typedef struct _student { char name[STR_LEN]; int gender; int age; } Student; #endif