嗨即时通讯新手这里也是新手编程和id就像你帮我这个:问题是,在编译和运行程序后,它在运行中停止在它的中间,我不知道是什么导致这和对不起的上一篇文章感到抱歉: 这是我的计划:
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");
}
这是一张清楚显示问题的图片:
答案 0 :(得分:3)
您需要传递变量的地址:
scanf("%d",&age);
^
答案 1 :(得分:1)
您在未初始化age
的值的内存位置处输入。即一些垃圾
使用:
scanf("%d",&age); // notice & , pass address of variable age