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

TOP

返回列表