getchar

    -2热度

    2回答

    while(1) { printf("1. ADD\n2. VIEW LIST\n3. QUIT\n"); int menu = 0 ; menu = getchar()-48; getchar(); switch(menu) { case 1: addition(book,count++); break; c

    -3热度

    1回答

    我弄不明白为什么我的getchar()函数不能按我希望的方式工作。我得到10没有2.请看看。 的Main(): #include <cstdlib> #include <iostream> #include <fstream> using namespace std; int main() { int var, newvar; cout << "enter a nu

    1热度

    1回答

    这里在read()函数中我使用getchar()它只读取一个字符。它打破循环,即使在,而条件()是事实,但getchar_unlocked(),直到给定的条件未能 代码是计算像最大值读取字符: input : 4 8-6+2+4+3-6+1 1+1+1+1 2+3+6+8-9 2+7+1-6 output : 10 //(which is max value of 3rd stri

    1热度

    3回答

    列表项 我有使用getchar() method.What我想是计算小组件模拟器与由用户的形式ADD Rx Ry下写入8个命令的问题其中Rx和Ry是寄存器。我不允许使用字符串和数组,所以唯一的选择是通过char读取char。 我的问题是,我不知道如何从输入一行文本读取多个字符,并把它放在variables.For例如,ADD Rx Ry我想存储在ch1A,D在ch2和D在ch3然后跳过空间验证R并

    0热度

    2回答

    我做了一个需要完成当进入EOF字符(按Ctrl-Z适用于Windows)和应打印一个简单的C程序: 通过的情况等级高于或等于5. 如果等级高于或等于8,则通过高通。 对于任何其他情况都失败。 我使用getchar()作为用户输入(在这种情况下的等级)。 #include <stdio.h> int main() { int grade; puts("Enter a grad

    1热度

    1回答

    我只是玩弄ncurses,所以,我发现了一个非常奇怪的行为。 当我使用initscr的()从ncurses的lib和事后我使用正常的getchar(),则程序按压第一键之后终止。 正常的getchar()行为我所期望的,是我可以输入(或多或少),只要等我按回车键。 #include "curses.h" int main() { initscr(); getchar();

    1热度

    3回答

    我想输入一个字符并获取相应的ASCII整数作为输出。我使用getchar()获取输入,并在while中创建一个无限循环,输入'q'时循环会中断。我的代码是 - #include <stdio.h> int main() { int c; printf("Enter a character(press q to exit):\n"); while(1) {

    -2热度

    3回答

    我想用putchar()和getchar()从用户中读取一串字符,然后我的循环将打印每个字符三次,打印新行等等,直到变量“userInput”中的每个字符都已经打印完毕。当我尝试编译我的节目,我收到以下错误: warning: assignment makes pointer from integer without a cast [enabled by default] userInput =

    3热度

    1回答

    我基本上想知道要放什么东西在过去printf语句第一%d,因为从我的理解getchar将输入的字符的ASCII码。那么如何显示输入的字符呢? #include <stdio.h> int main(void) { int c; printf("Enter a character: "); c = getchar(); printf("The ASCII

    1热度

    2回答

    我想从终端写入文件中的内容。文件正在创建但内容未写入文件。 #include<stdio.h> #include<stdlib.h> #include<math.h> int main(int argc, char *argv[]) { FILE *fp; fp=fopen(argv[1],"w"); char ch;