Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是的,所以我尝试了很多东西,但输出总是一团糟。这是一张显示发生了什么的图片。如您所见,字母变量变得很奇怪。
问题是它"letter: " + letter"没有做你认为它做的事情,它将 letter 的整数值添加到const char*string literal "letter"。最简单的解决方法是string("letter: ") + letter.
"letter: " + letter"
const char*
"letter"
string("letter: ") + letter