得到错误C1075。我的教授或我自己都不知道为什么。 [英] Getting an error C1075. Neither my professor or myself can figure out why.
本文介绍了得到错误C1075。我的教授或我自己都不知道为什么。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我计算了所有括号。注释掉除了主要的一切,仍然有这个错误。如果有人能提供帮助那就太棒了
#include< stdio.h>
#include< stdlib.h>
#include< string.h>
//定义
#define MAXCHR 40
#define MAXSTUDENT 10
//结构
struct student
{
char name [MAXCHR];
int id;
char major [MAXCHR];
char classLevel [MAXCHR];
};
// prototype
int printStudents(struct student students [],int numStudents);
char userChoice();
int main(void)
{
//声明
FILE * fpIN;
struct student students [MAXSTUDENT];
char fName [MAXCHR];
char lName [MAXCHR];
int i = 0;
int numStudents = 0;
char choice ='';
//打开文件检查错误
if((fpIN = fopen(" student.txt"," r"))== NULL)
{
printf(" Error opening student.txt");
退出(-1);
}
//读取文件和存储数据
while(!feof(fpIN))
{
fscanf(fpIN," ;%s%s%d%s%s",
fName [i],lName [i],& students [i] .id,& students [i] .major,& students [i ] .classLevel);
i ++;
}
do {
//调用userChoice
choice = userChoice();
//选择的开关语句
开关(选择)
{
案例'a':
案例'A':
printStudents;
休息;
案例'b':
案例'B':
for(i = 0; i< MAXSTUDENT; i ++)
{
if( strcmp(students [i] .classLevel," Senior")== 0)
{
printf("%s%d%s%s",
students [i]。姓名,学生[i] .id,学生[i] .major,学生[i] .classLevel);
}
}
休息;
case'c':
case'C':
for(i = 0; i< MAXSTUDENT; i ++)
{
if(strcmp(students [i] .major," Computer")== 0)
{
printf("%s%d%s%s",
students [i] .name,学生[i] .id,学生[i] .major,学生[i] .classLevel);
}
}
休息;
} //结束开关
} while(choice!='d'|| choice!='D');
return(0);
}
//输出所有学生信息的功能
int printStudents(struct student students [],int numStudents)
{
for(int i = 0; i< MAXSTUDENT; i ++)
{
printf("%s%d%s%s",
students [i] .name,students [i] .id,学生[i] .major,学生[i] .classLevel);
}
return(0);
}
//输出选项菜单的功能
char userChoice()
{
char choice;
//打印出选项菜单
printf(" \ n \ n请从菜单中选择一个选项:\ n \ n");
printf("a。打印出所有学生数据\ n");
printf(" b。打印所有Seniors学生信息\ nn);
printf(" c。打印所有计算机专业学生信息\ nn);
printf(" d。退出程序\ nn \ n");
scanf("%c",& choice);
返回(选择);
}
解决方案
< blockquote>
2017年5月17日下午12:44,Liferian写道:
我计算了所有括号。注释掉除了主要的一切,仍然有这个错误。如果有人能提供帮助那就太棒了
为我编译: http://rextester.com/FGEBFL26986 。如果存在问题,它必须位于您未显示的代码中。
I counted out all my brackets. Commented out everything but main and still got this error. If anyone could help that would be great
#include <stdio.h> #include <stdlib.h> #include <string.h> //define #define MAXCHR 40 #define MAXSTUDENT 10 //structure struct student { char name[MAXCHR]; int id; char major[MAXCHR]; char classLevel[MAXCHR]; }; //prototype int printStudents(struct student students[], int numStudents); char userChoice(); int main(void) { // declaration FILE *fpIN; struct student students[MAXSTUDENT]; char fName[MAXCHR]; char lName[MAXCHR]; int i = 0; int numStudents = 0; char choice = ' '; //open file check for error if ((fpIN = fopen("student.txt", "r")) == NULL) { printf("Error opening student.txt"); exit(-1); } //read file and store data while (!feof(fpIN)) { fscanf(fpIN, "%s %s %d %s %s", fName[i], lName[i], &students[i].id, &students[i].major, &students[i].classLevel); i++; } do { // call userChoice choice = userChoice(); //switch statement for the choice that was made switch (choice) { case 'a': case 'A': printStudents; break; case 'b': case 'B': for (i = 0; i < MAXSTUDENT; i++) { if (strcmp(students[i].classLevel, "Senior") == 0) { printf("%s %d %s %s", students[i].name, students[i].id, students[i].major, students[i].classLevel); } } break; case 'c': case 'C': for (i = 0; i < MAXSTUDENT; i++) { if (strcmp(students[i].major, "Computer") == 0) { printf("%s %d %s %s", students[i].name, students[i].id, students[i].major, students[i].classLevel); } } break; } // end switch } while (choice != 'd' || choice != 'D'); return(0); } //function to output all the students information int printStudents(struct student students[], int numStudents) { for (int i = 0; i < MAXSTUDENT; i++) { printf("%s %d %s %s", students[i].name, students[i].id, students[i].major, students[i].classLevel); } return (0); } //function to output option menu char userChoice() { char choice; //print out option menu printf("\n\nPlease Choose An Option From The Menu:\n\n"); printf("a. Print out all the students data\n"); printf("b. Print out all Seniors student information\n"); printf("c. Print out all Computer Major student information\n"); printf("d. Exit program\n\n"); scanf("%c", &choice); return (choice); }
解决方案
On 5/17/2017 12:44 PM, Liferian wrote:
I counted out all my brackets. Commented out everything but main and still got this error. If anyone could help that would be great
Compiles for me: http://rextester.com/FGEBFL26986 . To the extent there is a problem, it must lie somewhere in the code you haven't shown.
这篇关于得到错误C1075。我的教授或我自己都不知道为什么。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文