在仔细阅读网页和乱搞之后,我似乎无法将空*的目标(它是一个字符串)转换为std::string。我尝试过使用this page推荐的sprintf(buffer, "%p", *((int *)point));
来获取C字符串,但没有效果。不幸的是,是的,我必须使用空*,因为这就是SDL在他们的USEREVENT结构中使用的。
对于感兴趣的人,我用来填充Userevent的代码是:
std::string filename = "ResumeButton.png";
SDL_Event button_press;
button_press.type = BUTTON_PRESS;
button_press.user.data1 = &filename;
SDL_PushEvent(&button_press);
有什么想法吗?
编辑:感谢所有的响应,我只需要将void*转换为std::string*。我真傻。非常感谢你们!
https://stackoverflow.com/questions/3076968
复制相似问题