返回列表 發帖

字串處理 (三) - 字串輸入 2

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     char str[50];
  7.     cout<<"輸入一字串: ";
  8.     cin.getline(str,50);
  9.     cout<<"你剛輸入的字串是: "<<str<<endl;
  10.     system("pause");     
  11.     return 0;   
  12. }
複製代碼

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     char x[11];
  7.     cout<<"請輸入一段文字:";
  8.     cin.getline(x,11);
  9.     cout<<"輸出結果:"<<x<<endl;
  10.     system("pause");
  11.     return 0;
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     char str[10000];
  7.     cout<<"輸入一字串: ";
  8.     cin.getline(str,10000);
  9.     cout<<"你剛輸入的字串是: "<<str<<endl;
  10.     system("pause");     
  11.     return 0;   
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {

  7.     char str[50];
  8.     cout<<"輸入一字串"<<endl;   
  9.     cin.getline(str,50);
  10.     cout<<"你剛輸入的字串是: "<<str<<endl;
  11.    
  12.    system("pause");
  13.    return 0;


  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     char str[50];
  7.     cout<<"輸入一字串: ";
  8.     cin.getline(str,50);
  9.     cout<<"你剛輸入的字串是: "<<str<<endl;
  10.     system("pause");     
  11.     return 0;   
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     char str[50];
  7.     cout<<"輸入一字串";
  8.     cin.getline(str,50);
  9.     cout<<"你剛剛輸入的字串是:"<<str<<endl;   
  10.     system("pause");
  11.     return 0;
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.    char str[50];
  8.    cout<<"輸入一字串: ";
  9.    cin.getline(str,50);
  10.    cout<<"你剛剛輸入的字串是: "<<str<<endl;
  11.    
  12.    system("pause");
  13.    return 0;
  14. }
複製代碼

TOP

返回列表