gpt4 book ai didi

C程序运行中途停止

转载 作者:太空宇宙 更新时间:2023-11-04 06:31:08 24 4
gpt4 key购买 nike

嗨,我是新来的,我也是编程新手,我喜欢你帮助我解决这个问题:问题是在编译和运行程序后,它在运行时停在它的中间,我不知道是什么导致了这个和抱歉之前的帖子无法阅读:这是我的程序:

char answer[15];
char place[15];
char fullname[15];
int age;
printf("What Is Your Full Name?: ");
scanf("%s",fullname);
printf("What Is Your Age?: ");
scanf("%d",age);
printf("Where Do You Live?: ");
scanf("%s",place);

if(strcmp(place,"gafsa")==0) {
printf("Aint a bad place you know");
}
else{
printf("hmmm %s cool\n",place);
}

printf("your name is %s, %d year old from %s is that right?: ",fullname,age,place);
scanf("%s",answer);

if(strcmp(answer,"yes")==0){
printf("you my friend are awesome\n");
}
else{
printf("you suck\n");
}

这是一张清楚地显示问题的图片:

http://i.stack.imgur.com/yFTwK.png

最佳答案

需要传递变量的地址:

scanf("%d",&age);
^

关于C程序运行中途停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20456678/

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