返回列表 發帖
  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字內): ";
  9.     cin.getline(str,100);
  10.     cout<<"您請輸入的字串: "<<endl;
  11.     for(int i=0; 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

返回列表