返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a=0;
  7.     char str[100];
  8.     cout<<"請輸入字元(100字以內): "<<endl;
  9.     cin.getline(str,100);
  10.     cout<<"您輸入的字串為:";
  11.     for(int i=1; str[i]!=NULL; i++)
  12.     {
  13.         cout<<str[i];   
  14.         a++;        
  15.     }
  16.     cout<<endl;
  17.     cout<<"字串的長度是"<<a<<"個字元"<<endl;
  18.     system("pause");
  19.     return 0;
  20. }
複製代碼

TOP

返回列表