EOF 键盘输入end of file

矫情吗;* 2022-07-15 05:13 320阅读 0赞



Entering an End-of-file from the Keyboard从键盘输入文件结束符

Operating systems use different values for end-of-file. On Windows systems we enter an end-of-file by typing a control-zsimultaneously type the “ctrl” key and a “z.” On UNIX systems, including Mac OS-X machines, it is usually control-d.

操作系统使用不同的值作为文件结束符。Windows 系统下我们通过键入 control—z——同时键入“ctrl”键和“z”键,来输入文件结束符。Unix 系统中,包括 Mac OS—X 机器,通常用 control—d。

例子:

  1. #include <iostream>
  2. int main()
  3. {
  4. int sum=0,value=0;
  5. while(std::cin>>value)
  6. sum+=value;
  7. std::cout<<"sum is:"<<sum<<std::endl;
  8. return 0;
  9. }

Center

输入数据,之后,按ctrl +d ,输入结束

才能输出结果

发表评论

表情:
评论列表 (有 0 条评论,320人围观)

还没有评论,来说两句吧...

相关阅读