str=""
int main()
{
//test();
string str = "";
for (size_t i = 0; i < str.size(); i++)
{
cout << str[i] <<endl;
}
system("pause");
return 0;
}
输出结果:
以上代码表明,当str=""时,字符串是一个空串;
str=" "
int main()
{
//test();
string str = " ";
for (size_t i = 0; i < str.size(); i++)
{
cout << str[i] <<endl;
}
system("pause");
return 0;
}
以上代码表明,当str=" "时,字符串不是空串,而是只有一个空字符的串。