一个有意思的问题~~(此贴仅做讨论~ 没分)
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
int main()
{
// 提示: 如果'\0'输出的话, 会输出一个空格' '
string str = "123456789";
cout << str << "+" << endl;
str = "a\0b\0\0\0";
cout << str << "+" << endl;
str += '\0'; // 注意这里是单引号
cout << str << "+" << endl;
str += "\0";
cout << str << "+" << endl;
str += "\0\0";
cout << str << "+" << endl;
str += '\0c\0'; // 注意这里是单引号
cout << str << "+" << endl;
str += "\0d\0";
cout << str << "+" << endl;
str += "e";
cout << str << "+" << endl;
char c;
cin >> c;
}
/*
~~(此贴仅做讨论~ 没分)
大家不要运行~~先说出结果~~~
运行也可以~~
大家知道为什么吗????
为了计算空格数~~大家写出结果的时候请把空格替换成百分号'%'
*/