0
我想從用戶使用scanf獲得5浮點值,問題是用戶需要輸入6個值才能完成程序。 儘管我知道我不應該使用scanf,但它讓我感到困擾,有些事我無法理解。任何見解,關於如何在使用scanf時修復它的任何建議?scanf需要比請求更多的輸入
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i = 0 , j = 0;
char buf[128] = {0};
float numbers[5] = {0.0};
float keep = 0.0;
printf("Please input 5 numbers : \n");
for (i = 0; i < 5; i++)
{
scanf("%f\n", &numbers[i]);
}
printf("Done!");
感謝,
MIIJ