if (choice=1){
printf("Enter the name of the patient:\n");
scanf("%d", name);
printf("Enter the date of birth of the patient:\n");
scanf("%s", birthmonth, birthday, birthyear);
printf("Enter the gender of the patient:\n");
scanf("%s", gender);
printf("PRESS ANY KEY TO CONTINUE");
getch();
}
每当我运行这部分代码时,它只允许我输入患者的姓名。有人知道为什么会这样吗?
发布于 2021-04-16 05:28:22
在第一条scanf
语句中,字符串使用的是整数占位符(%d
),而不是(%s
)。
在第二个scanf
语句中,您应该使用3x %s
来获取三个变量的输入。
https://stackoverflow.com/questions/67119529
复制