gpt4 book ai didi

c - 这段代码有什么问题?

转载 作者:行者123 更新时间:2023-11-30 21:45:27 27 4
gpt4 key购买 nike

我不明白这段 C 代码有什么问题。我问这个只是出于学习目的。我知道这个游戏有点愚蠢,但它只是为了娱乐和学习。

#include <stdio.h>
int main(){
int response
char name [20];
printf ("Welcome to Game1\n");
printf ("What's your name?\n");
scanf ("%s",name);
printf ("From now on you're Private %s\n",name);
printf ("Loading...\n");
delay(4000);
printf("You are in a army excersize yard.\n");
delay(4000);
printf("Your sargeant approaches.\n");
printf ("Sargeant Sam: Drop and give me twenty, Private %s\n",name);
printf ("1) Yessir!\n2)Make me\n");
scanf ("%d\n", response);
if(response==1){
printf ("You do 20 pushups\n");
}
if(response==2){
printf("Sargeant Sam: What did you say?!\n");
}
return (0);
}

这些是错误

game1.c: In function ‘main’:
game1.c:4: error: nested functions are disabled, use -fnested-functions to re-enable
game1.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘char’
game1.c:16: error: ‘response’ undeclared (first use in this function)
game1.c:16: error: (Each undeclared identifier is reported only once
game1.c:16: error: for each function it appears in.)

我是一个完全的初学者,所以请简单地解释一切。

最佳答案

int main(){
int response
^

这里缺少分号。

关于c - 这段代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17793819/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com