我正在使用C++字符串,並且是編程初學者。爲什麼這個C++字符串連接缺少一個空格?
我期待:99紅氣球
但我收到:99 RedBalloons
這是爲什麼?
#include <string>
#include <iostream>
using namespace std;
int main()
{
string text = "9";
string term("9 ");
string info = "Toys";
string color;
char hue[4] = {'R','e','d','\0'};
color = hue;
info = "Balloons";
text += (term + color + info);
cout << endl << text << endl;
return 0;
}