编译以下代码时出现错误,错误告诉我必须将 unsigned short 转换为 char,我不知道如何执行此转换。我正在使用 vc6 MFC。这是我使用的代码。
SYSTEMTIME st;
GetSystemTime(&st);
unsigned short time = st.wHour;
MessageBoxA(TEXT(time),"system time",MB_OK);
最佳答案
您可以使用 std::ostringstream
:
#include <sstream>
...
std::ostringstream time;
time << st.wHour;
MessageBoxA(time.str().c_str(),"system time",MB_OK);
关于c++ - 在 msgbox 中显示当前系统时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9063732/