C++ primer ——3.2.3节

来源:互联网 发布:java 断点 编译后 存在 编辑:程序博客网 时间:2024/06/03 19:10
//3.6#include<iostream>#include<string>#include<cctype>using std::string;using std::cout;int main(){    string s("hello");    for (int index = 0; index < s.size(); index++)        s[index] = 'T';    cout << s;    return 0;}
//3.10#include<iostream>#include<string>using std::cout;using std::string;using std::endl;int main(){    string s("hello,world !");    for (string::size_type index = 0; index < s.size(); index++)    {        if (ispunct(s[index]))        {            string::size_type n = index;            for (; n < s.size() - 1;n++)                s[n] = s[n + 1];        }        cout << s[index] << endl;    }    cout << s;    return 0;}//用数组存在BUG如何解决
#include<iostream>#include<string>using std::cout;using std::string;int main(){    string s("hello,world!");    for (auto c : s)    {        if (!ispunct(c))        {            cout << c;        }    }    return 0;}
0 0