我剛開始學習c,並且正在閱讀有關輸入的內容。假設我需要一個c程序,用於識別您輸入的是數字還是字符串(不只是一個字符),然後打印出來。 Somethihng這樣的:確定輸入是數字還是字符串,然後將其打印回來
int input, is_digit;
is_digit = scanf("%d", input);
printf("Please enter a digit or a string and then a newline\n");
if (is_digit)
printf("You entered the digit: %d", &input);
else
printf("You entered the string: %s", &input);
這不起作用,如預期,但我寫它給的什麼,我試圖完成一個想法。
你會如何在C中做到這一點?