热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

getch计算机错误,getch()显示原型错误

我的理解是客观的:我想要显示的结果后方案保持开放何乐而不为呢典型的c方式?#includeintmain(void){inti;charch;std::

我的理解是客观的:

我想要显示的结果后

方案保持开放何乐而不为呢典型的c++方式?

#include

int main(void)

{

int i;

char ch;

std::cout<

std::cin.get(ch); // For testing enter a string at this step say "String"

/* The input to cin is line-buffered, so after reading &#39;S&#39; to ch,

* the remaining "tring" is still in the buffer.

*/

std::cout<

while(std::cin.get()!&#61;&#39;\n&#39;)

;;

/* cin.get() is an overloaded function in the istream class.

* If no arguments are passed to &#39;get()&#39; this function reads single next character

* In essence, we wait for the cin.get() to clear the buffer that is

* read all characters including &#39;\n&#39;

*/

std::cout<

std::cin.get();

/* Since we have already cleared the buffer using the loop

* &#39;get()&#39; expects us to enter a character this time

*/

return 0;

}



推荐阅读
author-avatar
Yy石小雪
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有