#include <stdio.h> #include <stdbool.h> int main(void) { float input; bool isTrue = (scanf("%f",&input) == 1); while(isTrue) { printf("it's %.d\n",(int)input);//輸入的小於1就不會打印出來 isTrue = (scanf("%f",&input) == 1); } }
/*當只需獲取一個輸入時,能夠向下面的這樣作*/ #include <stdio.h> int main(void) { char boop; while(scanf("%c",&boop) == 1) { while(getchar() != '\n') continue; printf("It's %c",boop); } } //等同於下面的程序 #include <stdio.h> int main(void) { char boop; while(gets(&boop)) { printf("It's %c",boop); } }