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
我弄不明白为什么我的getchar()函数不能按我希望的方式工作。我得到10没有2.请看看。 的Main(): #include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
int main() {
int var, newvar;
cout << "enter a nu
这里在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
我做了一个需要完成当进入EOF字符(按Ctrl-Z适用于Windows)和应打印一个简单的C程序: 通过的情况等级高于或等于5. 如果等级高于或等于8,则通过高通。 对于任何其他情况都失败。 我使用getchar()作为用户输入(在这种情况下的等级)。 #include <stdio.h>
int main() {
int grade;
puts("Enter a grad
我想输入一个字符并获取相应的ASCII整数作为输出。我使用getchar()获取输入,并在while中创建一个无限循环,输入'q'时循环会中断。我的代码是 - #include <stdio.h>
int main() {
int c;
printf("Enter a character(press q to exit):\n");
while(1) {
我想用putchar()和getchar()从用户中读取一串字符,然后我的循环将打印每个字符三次,打印新行等等,直到变量“userInput”中的每个字符都已经打印完毕。当我尝试编译我的节目,我收到以下错误: warning: assignment makes pointer from integer without a cast [enabled by default]
userInput =
我基本上想知道要放什么东西在过去printf语句第一%d,因为从我的理解getchar将输入的字符的ASCII码。那么如何显示输入的字符呢? #include <stdio.h>
int main(void) {
int c;
printf("Enter a character: ");
c = getchar();
printf("The ASCII