C程序在运行过程中停止

时间:2013-12-08 17:43:25

标签: c

嗨即时通讯新手这里也是新手编程和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");
}

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

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

2 个答案:

答案 0 :(得分:3)

您需要传递变量的地址:

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

答案 1 :(得分:1)

您在未初始化age的值的内存位置处输入。即一些垃圾

使用:

scanf("%d",&age); // notice & , pass address of variable age