- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- string str1="hello";
- cout<<str1<<endl;
-
- char str2[6]="hello";
- for(int i=0; i<=4; i++)
- cout<<str2[i];
- cout<<endl;
-
- char str3[5]={'h','e','l','l','o'};
- for(int i=0; i<=4; i++)
- cout<<str3[i];
- cout<<endl;
-
- string str4[2]={"he","llo"};
- for(int i=0; i<=1; i++)
- cout<<str4[i];
- cout<<endl;
- system("pause");
- return 0;
- }
複製代碼 |