getchar

    -4熱度

    2回答

    我用C編寫一個程序,要求用戶輸入一個數字範圍。恩。 1 4 6 9 5並找到它們中最大的一個。這看起來很簡單,但我一直得到錯誤的結果。 到目前爲止我的代碼我寫的是: #include <stdio.h> #include <stdlib.h> main() { char max; int count = 0; char numbers; print

    1熱度

    1回答

    這是一個程序打印一個方形的side =整數由一個字符組成。 對於例如:如果輸入的字符輸出爲#: 但是它不讀取用戶輸入,並且因此也未能將其打印在正方形。 請參見下面的代碼: //printing of square of any character problem 5.20 #include<stdio.h> int main(void) { int i, h;

    -1熱度

    2回答

    我有一個程序,提示用戶輸入一個不是負數或字符的整數。我想提示用戶輸入一個浮點數。我該怎麼做呢? do { printf("Enter a number.\n"); } while(((scanf("%d%c", &x1, &term) != 2 || term != '\n') && reset_stdin()) || x1 < 1); int reset_stdin

    -3熱度

    4回答

    是否有像getline或getchar這樣的功能,即使char爲空格,它也會得到下一個字符?所以如果我有a bc,我將不得不四次調用該函數以獲得'a',' ','b'和'c'。

    -1熱度

    1回答

    我想讓我的程序使用帶有getchar的命令行參數來編碼消息。我的問題是,getchar只關注程序執行後輸入的內容。我怎樣才能讓它讀取命令行參數呢? #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int pin, charin, charout; // this veri

    -1熱度

    2回答

    此程序需要讀取兩個字符串,這兩個字符串將傳遞給「確認」功能,它們將被讀取,並且該函數將具有找到一個共同的詞。 但在主要我不能讀取「string2」字符串!不管我插入多少個getchar。對於\n串1的輸入之後 #include <stdio.h> #include <string.h> void confirm(char string1[],char string2[]){ ch

    -1熱度

    1回答

    我的代碼沒有問題。我嘗試使'while'循環讀取我所有的輸入值,然後停止當我點擊EOF。我已經讀過Windows中的EOF是CTRL + Z等,但我的'while'不想停止,並且在所有輸入值和CTRL + Z之後,它保持並等待下一個值。 這是我的代碼,希望您能幫幫我謝謝): #include <stdio.h> #include <stdbool.h> #define gc getchar

    0熱度

    2回答

    示例代碼是(註釋是什麼我想它做的第一循環): #include <stdio.h> #define BACKSPACE 8 main() { int c; while((c = getchar()) != EOF) //output: GODDAMN NOTHING cursor on: 'h' { //if the input is "h

    3熱度

    2回答

    我試圖從用戶獲取單個字符輸入,而用戶不必按Enter鍵。我已經試過這樣: #include <stdio.h> int main() { int input; for (;;) { input = getchar(); printf("%d\n", input); } } 但不是隻做用戶需要按下回車鍵,還註冊了兩個印刷機(輸入字符和

    1熱度

    3回答

    當我輸入a時,輸出爲not a。條件是真的那麼爲什麼輸出not a?當我使用getchar而不是scanf_s時,它工作正常。有什麼問題? char op; scanf_s("%c", &op); if (op == 'a') { printf("the character is a"); } else { printf("not a"); }