简体   繁体   中英

Why can't I display chars properly in C++ WinForms Message Box?

So I'm having trouble concatenating strings and chars and then displaying them using the message box because my characters get printed as numbers, and when I try to convert them to string no matter where or how the message box throws an error! Any help is appreciated!

MessageBox::Show("The most common letter is \"" + letters[biggetsNumberIndex] + "\".");
// Simplified version: MessageBox::Show("string" + 'c' + "string");

I managed to fix it thanks to "Jimi" I changed the "letters" variable instead of character array or std::string I used String^

// Bad
std::string letters = "abcdefghijklmnopqrstuvwxyz";

// Good
String^ letters = "abcdefghijklmnopqrstuvwxyz";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM