18.6 上机实践习题

    定义一个字符串对象,然后将接收用户的输入,最后将输入结果输出。

    【提示】上述题目主要是要求读者熟悉字符串类的相关知识,重点是掌握字符串类的概念和使用。

    【关键代码】


    01 #include<string> 02 using namespace std; 03 04 string str; 05 cout<<"请输入字符串"<<endl; 06 cin>>str; 07 cout<<"您输入的字符串是:"<<str<<endl;