C语言结构体章节问题
课件中的相同的代码:# include <stdio.h>
void main ()
{
struct {
int num;
char *name;
char sex;
float score;
} boy1, boy2;
boy1.num = 007;
boy1.name = "jane";
printf("please input sex and score:\n");
scanf("%c %f", boy1.sex, boy1.score);
boy2 = boy1;
printf("Number = %d\nName = %s\n",boy2.num, boy2.name);
printf("Sex = %c\nScore = %f",boy2.sex, boy2.score);
}
在C-Free 5.0中编译后运行输入东西后就卡顿,然后退出程序,不能输出boy2的元素,求解答????? 将
scanf("%c %f", boy1.sex, boy1.score);
改为
scanf("%c %f", &boy1.sex, &boy1.score);
试试? BestLoveS 发表于 2015-8-3 21:28
将
scanf("%c %f", boy1.sex, boy1.score);
改为
小问题没发现,帮大忙了,谢谢!!
页:
[1]