C++ 如何在字符串中添加空格

C++ 如何在字符串中添加空格,c++,C++,在HTML中,您基本上添加了“ ”,因此它将创建一个空格,但我不知道如何在c中这样做++ 代码: stringword=”“; cout>单词; coutcoutChange cout << "your word is" << word<<""; cout只需在“is”后面加一个空格即可: “您的单词是”在C++中读取空格并不难,因为它是字符串文字。为了回答您的问题,在输出中添加空格的最简单方法是修改cout语句iteslf,在需要的地方添加空格。在

在HTML中,您基本上添加了“ ”,因此它将创建一个空格,但我不知道如何在c中这样做++ 代码:

stringword=”“;
cout>单词;
cout
coutChange

cout << "your word is" << word<<"";
cout只需在“is”后面加一个空格即可:


“您的单词是”在C++中读取空格并不难,因为它是字符串文字。为了回答您的问题,在输出中添加空格的最简单方法是修改cout语句iteslf,在需要的地方添加空格。在你的情况下,它会像:(还增加了一些提示)

字符串字;//无需在此处将单词定义为空白;稍后您将把它作为输入
cout>单词;

cout@LotBajrami Np。很乐意帮忙。只要把“你的话是”改为“你的话是”(注意结尾的空格)。这是一个字符串文本,不需要任何特殊的编码。
cout << "your word is " << word;
cout << "your word is" << word<<"";
cout << "your word is " << word<<"";
//                 ^^^^
"your word is " <<
string word; // unrequired to define word as blank here; you will take it as input later
cout << "give a word: "; // Added a space after "word"
cin >> word; 
cout << "Your word is " << word << endl; // you do not need "" because that outputs nothing. If you want to print a new line, use "endl" or "\n".