scanf函数返回值的具体应用 #include <stdio.h> int main() { int ch; while (scanf("%d", &ch) == 1 && ch >= 0) ; return 0; } 当输入值不是自然数时,程序就能正常退出。