我只需要连接一个文件路径,在 C++ 中使用库 SDL Mixer 2.0:
像这样:
#include<SDL2/SDL_mixer.h>
string myColor = "red";
sound = Mix_LoadWAV("D:\\car"+myColor+".wav"); //or this
sound = Mix_LoadWAV("D:\\car"+"red"+".wav");
// is generate a error:
#define Mix_LoadWAV(file)
最佳答案
Mix_LoadWAV收到一个 char *file
所以你需要将 std::string
转换为 char*
sound = Mix_LoadWAV(("D:\\car" + myColor + ".wav").c_str());
关于c++ - 如何连接文件路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56140551/