C——为什么scanf需要输入两次

float hours,tax,wage;
    printf("Please enter your working hours:");
    scanf_s("%f\n", &hours);

原因:scanf函数里含有换行符,输入时换行符被回车忽略了,需要再次输入。

scanf的printf的用法不同,实际上输入两个数据,只有第一个起作用,第二个是无效的。

posted @ 2020-02-20 15:02  Mqqq  阅读(924)  评论(0)    收藏  举报