(C语言)请问出了什么问题导致最后运行出来没有下半部分的内容?

#include<stdio.h>
#include<math.h>
#include<string.h>
#define N 3
#define M 3
int num=0;
void cover();
int password();
void question();
int main(){
int pw,n,answer;
int score=0;

cover();
printf("\n按任意键继续!");
char c=getchar();
system("cls");
if(password())
{
void question();
printf("\n谢谢使用,再见!");
}
else
printf("\n谢谢使用,再见!\n\n");
system("pause");
}
void cover(){
int m;
for(m=0;m<=20;++m){
printf("*");

}
printf("\n\n\n");
printf("欢迎测试!");
printf("\n\n\n");

for (m=0;m<=20;++m)
printf("*");
printf("\n\n");

}
int password(){
int pw;
int count=3;
while(count){
printf("\n请输入用户名和密码(123):\n");
char pw[8];
char user[8];
scanf("%s%s",user,pw);
if(strcmp(user,"123")==0 && strcmp(pw,"123")==0)
{
printf("\n测试开始!\n");
return 1;
break; }
else{
count--;
if(count==0)
{
printf("\n您输入的密码错误3次!,退出程序:\n");
return 0;
}
else{
printf("\n您输入的密码错误,请重新输入:\n");
}

void question(){
int x,y,answer;
char fuhao;
int t;
int score=0;
int i;
for(i=0;i<M;i++)
{printf("Please select +,-\n");
scanf(" %c",&fuhao);
srand((unsigned)time(0));
x=rand()%100;
y=rand()%100;
if(fuhao=='+'){
printf("%d+%d=",x,y);
scanf("%d",&answer);
if(answer==(x+y)) score+=10;

}
else
if(fuhao=='-'){
if(x<y){t=x;x=y;y=t;}
printf("%d-%d=",x,y);
scanf("%d",&answer);
if(answer==(x-y))
score+=10;
}
}
printf("Your score:%d\n",score);}
}
}

}
}

主函数里面的question是声明不是调用

把void去掉就好了

追问

但是去掉的话编译不出,会显示[Error] ld returned 1 exit status

追答

那是哪里出编译错误了,最可能的就是你这个函数没有声明,再最上面声明一下就好了

你可以把完整的错误信息发上来,在ld之前应该还有其他错误

找到原因了,你的question函数写到password里面了

#include
#include
#include
#include
#include
#define N 3
#define M 3
int num=0;
void cover();
int password();
void question();
int main(){
int pw,n,answer;
int score=0;

cover();
printf("\n按任意键继续!");
char c=getchar();
system("cls");
if(password())
{
question();
printf("\n谢谢使用,再见!");
}
else
printf("\n谢谢使用,再见!\n\n");
system("pause");
}
void cover(){
int m;
for(m=0;m<=20;++m){
printf("*");

}
printf("\n\n\n");
printf("欢迎测试!");
printf("\n\n\n");

for (m=0;m<=20;++m)
printf("*");
printf("\n\n");

}
int password(){
int pw;
int count=3;
while(count){
printf("\n请输入用户名和密码(123):\n");
char pw[8];
char user[8];
scanf("%s%s",user,pw);
if(strcmp(user,"123")==0 && strcmp(pw,"123")==0)
{
printf("\n测试开始!\n");
return 1;
break; }
else{
count--;
if(count==0)
{
printf("\n您输入的密码错误3次!,退出程序:\n");
return 0;
}
else{
printf("\n您输入的密码错误,请重新输入:\n");
}

}
}

}

void question(){
int x,y,answer;
char fuhao;
int t;
int score=0;
int i;
for(i=0;i<M;i++)
{printf("Please select +,-\n");
scanf(" %c",&fuhao);
srand((unsigned)time(0));
x=rand()%100;
y=rand()%100;
if(fuhao=='+'){
printf("%d+%d=",x,y);
scanf("%d",&answer);
if(answer==(x+y)) score+=10;

}
else
if(fuhao=='-'){
if(x<y){t=x;x=y;y=t;}
printf("%d-%d=",x,y);
scanf("%d",&answer);
if(answer==(x-y))
score+=10;
}
}
printf("Your score:%d\n",score);}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2021-11-29
没有执行完的主要可能性就是有两个:
1,有阻塞的系统调用
这个的scanf 就是一个阻塞调用,需要等待输入;
可以试试不断在控制台输入需要的内容。

2,有死循环产生
while(count){
如果count处理不当就有可能产生死循环
相似回答