第一个C++程序
#include <iostream>
using namespace std; //std名字空间
int main()
{
//cout:标准输出
// cout << 把后面的东西塞到cout中
// endl 换行
cout << "Hello,World! I am " << 18 << "Today!" << end;
int number;
cin >> number;
cout << "You are " << number << ".";
return 0;
}
IDE:集成开发环境
eg: Eclipse
//*********************************
//Name: Hello.cpp
//Author:
//Version:
//Copyright:
//Description:
//*********************************
Eclipse
(1). 不小心console关闭,则菜单Windows—Show View—Console
(2). 若程序死循环,则点击红色的框框
之后出现
界面出现terminated,表示程序停止.
(3). 程序运行,若再点击运行按钮
则会出现
则有2个Console, 必须关闭其中一个.
Eclipse使用技巧
-
(1). 替换
-
eg: 将number换为age
选中number右键Refactor(重构)->Rename,改为age
(2). 写完程序直接点击运行按钮即可.
- 原因:运行时,eclipse后台若发现没有编译,则会自动启动编译按钮