返回列表 發帖
  1. //字串處理 (4種方式)
  2. #include<iostream>
  3. #include<cstdlib>
  4. using namespace std;
  5. int main()
  6. {
  7.     string str1="Hello! My name is Kyan!";
  8.     cout<<str1<<endl;
  9.    
  10.     char str2[7]={"Hello!"};
  11.     cout<<str2<<endl;

  12.     char str3[6]={'H','e','l','l','o','!'};
  13.     for(int i=0; i<=5; i++)
  14.         cout<<str3[i];
  15.     cout<<endl;
  16.    
  17.     string str4[5]={"Hello! ","My ","name ","is ","Kyan!"};
  18.     for(int i=0; i<=4; i++)
  19.         cout<<str4[i];
  20.     cout<<endl;
  21.    
  22.     system("pause");
  23.     return 0;   
  24. }
複製代碼

TOP

返回列表