#include<iostream>
#include <string>
#include <typeinfo>
using std::string;
using std::cout;
using std::cin;
using std::endl;
int main()
{
string str{"hello world!!!"};
int count = 0;
for ( decltype(str.size()) index = 0; index!=str.size() && !isspace(str[index]); ++index)
{
str[index] = toupper(str[index]);
}
cout << str << endl;
system("pause");
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
const char *cStr = "hello\0world";
string str{ 'a', 'b', '\0', 'c' };
string str1("world\0hello");
string str2("12");
printf("cStr = %s\nstr = %s, str1 = %s \n", cStr, str.c_str(), str1.c_str());
cout << "str = " << str <<", "<< " str1 = " << str1 << endl;
cout << "str.size = " << str.size() << endl;
cout << "str1.size = " << str1.size() << endl;
cout << "str2.size = " << str2.size() << endl;
system("pause");
return 0;
/*string不以\0结尾
读取string至\0结束*/
}