求教:在C++中getche()是什么啊

sl09123823 2011-04-10 04:54:55
求教:在C++中getche()是什么啊
请大侠给个简单的介绍,小弟初学C++
谢谢
...全文
549 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hongwenjun 2011-04-10
  • 打赏
  • 举报
回复
cin.get()
莫二先生 2011-04-10
  • 打赏
  • 举报
回复
你的程序开头(规范后):
#include<iostream.h>
#include<conio.h>
int add(int x,int y);
int main()


int add(int x,int y);

这句是add函数的声明,告诉编译器你在后面定义了这样的一个add函数。
莫二先生 2011-04-10
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 sl09123823 的回复:]

#include<iostream.h>
#include<conio.h>int add(int x,int y);int main()
{
cout<<"In main():\n";
int a,b,c;
cout<<"Enter two numbers:\n";
cin>>a>>b;

cout<<"\nCalling add():\n";
c=add(a,b);

……
[/Quote]
就是说add函数有两个形参,调用时需要向函数传递两个int型的值,就像主程序中的:
c=add(a,b);

add函数的功能是输出传入的两个值x和y,并返回(x+y)的值,主程序中将这个值赋给了c。。
sl09123823 2011-04-10
  • 打赏
  • 举报
回复
#include<iostream.h>
#include<conio.h>int add(int x,int y);int main()
{
cout<<"In main():\n";
int a,b,c;
cout<<"Enter two numbers:\n";
cin>>a>>b;

cout<<"\nCalling add():\n";
c=add(a,b);

cout<<"\nBack in main():\n";
cout<<"c was set to"<<c<<endl;

cout<<"\nExiting...\n";
getche();
}

int add(int x,int y)
{cout<<"In add(),received"<<x<<"and"<<y<<endl;
return x+y;
}

再请教标注颜色的是什么意思呀
sl09123823 2011-04-10
  • 打赏
  • 举报
回复
#include<iostream.h>
#include<conio.h>int add(int x,int y);
int main()
{
cout<<"In main():\n";
int a,b,c;
cout<<"Enter two numbers:\n";
cin>>a>>b;

cout<<"\nCalling add():\n";
c=add(a,b);

cout<<"\nBack in main():\n";
cout<<"c was set to"<<c<<endl;

cout<<"\nExiting...\n";
getche();
}

int add(int x,int y){
cout<<"In add(),received"<<x<<"and"<<y<<endl;
return x+y;
}

再请教标注颜色的是什么意思呀
arong1234 2011-04-10
  • 打赏
  • 举报
回复
读字符阿?迫使你程序等待你输入,防止程序直接结束[Quote=引用 3 楼 sl09123823 的回复:]
谢谢
还有那么这个getche()出现在程序的末尾是什么意思呢
[/Quote]
sl09123823 2011-04-10
  • 打赏
  • 举报
回复
谢谢
还有那么这个getche()出现在程序的末尾是什么意思呢
arong1234 2011-04-10
  • 打赏
  • 举报
回复
早年getch有几个变种:getche带回显输入,每个输入都打印到屏幕上,getch不带回显,不显示在屏幕上。getchar从标准输入读入,只有输入回车才开始输入

现在输入都用GUI了,这些东西已经不重要了
sl09123823 2011-04-10
  • 打赏
  • 举报
回复
自己来占个沙发
请高手回复呀
谢谢!!!!!!!!!!!!!!!

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧