我希望以下程序在等待输入字符时停止两次。第一次停止并等我键入一个字符时,我键入了一个字符然后按回车键,但是控制台没有等我输入'char c'之后,它只是结束并打印出我输入的内容' char b'。这是为什么?
#include <iostream>
using namespace std;
int main() {
char b;
cin.get(b);
char c;
cin.get(c);
cout << b << c << endl;
}
答案 0 :(得分:3)
问题陈述:
1)按下键盘上的某些键。
2)键盘上的另一个键标有&#34; Enter&#34;被压了。
流行测验:输入了多少个字符?
答案:输入了两个字符。
第一个*http.Request
读取第一个字符。第二个get()
读取第二个字符get()
键。(*)
(*)上面的答案假设一个非多字节的语言环境。
答案 1 :(得分:1)
使用:
//
// Created by dylan on 7/3/16.
//
#ifndef TEMPCONVERSION_FUNCTIONS_H
#define TEMPCONVERSION_FUNCTIONS_H
#include <iostream>
int choice;
int degrees;
double degrees2;
double f2c()
{
std::cout << "Enter the degree count in whole numbers \n";
std::cin >> degrees;
degrees2 = (degrees-32)/1.8;
std::cout << degrees2;
}
double c2f()
{
std::cout << "Enter the degree count in whole numbers \n";
std::cin >> degrees;
degrees2 = (degrees * 1.8) + 32;
std::cout << degrees2;
}
#endif //TEMPCONVERSION_FUNCTIONS_H