C语言新手问题

#include <stdio.h>int main(void){ int age; // variable float assets; // variable char pet[30]; // string printf("Enter your age, assets, and favorite pet.尀n"); scanf_s("%d %f", &age, &assets); // use the & here scanf_s("%s", pet); // no & for char array printf("%d $%.2f %s尀n", age, assets, pet); int d; scanf_s("%d", &d);}为毛我输入了字符dog给 pet ,但是没有显示 dog。。。还有控制台打印后就一闪而过,怎么让他留下来?int d;scanf_s("%d", &d);这个根本就不给机会输入。。。我也不懂怎么回事一共三个问题,还望详细解答用的是Visual Studio 2013
2026年09月28日 07:11
有3个网友回答
网友(1):

代码可以运行啊,我用的是codeblocks

网友(2):

你把%f,%d做两次输入。
不行,就在输入语句前面加getchar ();

网友(3):

scanf_s改成scanf