第一個C++程式
#include <iostream> //包含iostream頭檔案,C++中有關輸入輸出的函式都在這頭檔案中定義
#include <cstdlib> //cstdlib是標準函式庫的縮寫,有許多實用的函式
using namespace std;
int main()
{
cout<<"我的第一個C++程式"<<endl; //cout是C++語言的輸出指令,其中endl表示換行
system("pause"); //讓程式輸出結果暫停,等用戶按下任意鍵后才退出程式的輸出視窗
return 0;
}
二、C++的頭檔案
| C++頭檔案 |
|---|
| cmath |
| cstdio |
| cstring |
| iostream |
| fstream |
在程式代碼最后的return陳述句前要加上
system("pause");
必須等我們按下任意鍵之后程式才會繼續運行
四、命名空間
using namespace std;
五、輸出、輸入功能簡介
cout<<變數1或字串1<<變數2或字串2<<...<<變數n或字串n; //輸出
cin>>變數1>>變數2....>>變數n;
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/265424.html
標籤:其他
下一篇:Handler原始碼分析
