我
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main ()
{
int use;
int key;
int pass,i;
int a;
do
{
menu (a);
switch(a)
{
case 1:
for(i=1;i<5;i++)
{
printf("Please enter your username and password \n");
scanf("%d",&use);
printf("");
scanf("%d",& pass);
if (use ==711 && pass ==90210)
{
printf("\n Student Name");
printf("\n student subjects/student letter grade");
printf("\n");
printf("\n");
printf("\n");
printf("\t\t student GPA");
printf("\n Please enter any key to exit");
scanf("%d",& key);
break;
}
}
case 2:
for(i=1;i<5;i++)
{
printf("Please enter your username and password \n");
scanf("%d",&use);
printf("");
scanf("%d",& pass);
if (use ==911 && pass ==90211)
{
printf("Would you like to update student grades?");
}
break;
}
case 3:
for(i=1;i<5;i++)
{
printf("Please enter your username and password \n");
scanf("%d",&use);
printf("");
scanf("%d",& pass);
if (use ==1011 && pass ==90215)
{
printf("\n below the amount of users that accessed the system today");
printf("\n **********");
printf("\n");
}
break;
default:
printf("Please try agagin");
}
}
} while (a!=4);
return 0;
getch();
}
int menu(a)
{
printf("\t Welcome to Ski Academy Portal");
printf("\n 1. Student \t");
printf("\n 2. Staff \t");
printf("\n 3. Administrative \t");
printf("\n 4. Exit \t");
printf("\n Please enter your number choice \n");
scanf("%d",&a);
return 0;
}
答案 0 :(得分:0)
您的错误似乎与menu
在您尝试使用之前没有声明的事实有关。警告:
warning: implicit declaration of function ‘menu’
相当不言自明。取决于编译器,它将流向链接阶段并生成ld returns -1 error
,因为链接器无法找到名为menu
的函数的定义。
在包含后,在代码顶部创建menu
声明。 e.g。
...
#include<string.h>
int menu(a);
int main (void) {
...
或者最好:
int menu (int a);
另请注意'i'
和'a'
在main()
中未初始化使用。在尝试使用它们之前,请确保为它们提供值。
使用-Wall -Wextra
进行编译(例如启用警告)将以简洁的方式告诉您所有这些。