最初のC++プログラム

1204 ワード

バックグラウンドの言葉は気持ち悪い.いつもあの黒々としたコンソールに直面しなければならない.


#include 
 
   
    
  

using namespace std;



void Hello(string const name){

    cout << "Hello! " << name << "!" << endl;

}



int main(){

     Hello("C++");

     while(1);

}


 
   

インタラクティブ機能の追加:


#include 
 
   
    
  

using namespace std;



void Hello(string const name){

    cout << "Hello! " << name << "!" << endl;

}



int main(){

    string name;

    cout << "       ";

    getline(cin,name);//getline       ,    

    Hello(name);

    while(1);

}


 
   


#include 
 
   
    
  

using namespace std;

void Hello(string const name){

    cout << "Hello! " << name << "!" << endl;

}


 
   

ウィンドウを自動的に閉じない別の方法:


#include 
 
   
    
  

int main(){

    using namespace std;

    cout << "      ,      。"<< endl;

    cin.get();

    cin.get();

    return 0;

}