外网网站建设调研报告,网站建设的要求有哪些方面,网站开发要学,购物网站 功能cin/cout 数据类型自动识别/使用简单#xff0c;缺点是速度慢。若遇到比较大的数据规模#xff0c;很大可能被卡。改掉这个习惯#xff01; scanf()和getchar()函数是从输入流缓冲区中读取值的#xff0c;而不是从键盘终端缓冲区读取。 读取字符时#xff0c;scanf()以spa… cin/cout 数据类型自动识别/使用简单缺点是速度慢。若遇到比较大的数据规模很大可能被卡。改掉这个习惯 scanf()和getchar()函数是从输入流缓冲区中读取值的而不是从键盘终端缓冲区读取。 读取字符时scanf()以space enter tab 结束一次输入不会舍弃最后的回车符。会读取回车符 getchar()以 enter 结束输入也不会舍弃最后的回车符。 1 #includeiostream2 #includestring3 #includestdio.h4 using namespace std;5 int main()6 {7 char ch1,ch2;8 scanf(%c,ch1);9 scanf(%c,ch2);
10 printf(%d %d\n,ch1,ch2);
11 return 0;
12 }
13
14 #includeiostream
15 #includestring
16 #includestdio.h
17 using namespace std;
18 int main()
19 {
20 char ch1,ch2;
21 ch1getchar();
22 ch2getchar();
23 printf(%d %d\n,ch1,ch2);
24 return 0;
25 } 只读入一个字符 gets()只可读入字符串。char形式 读取字符串时scanf()以 space enter tab 结束一次输入。只读一个单词 回到空格结束读入 gets()以 enter 结束输入接受空格舍弃最后的回车符。不读取回车符读一整行 包括空格 getline 读入整个string string形式读一整行 包括空格 转载于:https://www.cnblogs.com/Kaike/p/9787232.html