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"); }