進階版 Hello, World!

目標:

Step 1:

先在程式碼中打好基礎架構 (請參第一個c++程式碼 Step 1)

Step 2:

在main函式中加入以下程式碼

string s;
cin >> s;
cout << "Hello, " << s ;

Step 3:

完成

詳細解析

string s;

string 我們稱為「資料型別」,s則稱為「變數」

所謂變數,就像是數學中的 xx ,xx可以是1, 2, 3, 0,8 ..,和數學不同的是,我們必須規定 xx 的種類,在這邊,我們規定變數 s 必須是字串(string),而字串又是什麼?參考以下連結吧XD

請參考這篇

ps. 點進連結後,就跟著那個網頁繼續學吧~

Last updated

Was this helpful?