"Mike" <> wrote in message
news:00999645-8a24-4246-960b-
> Hi
> filepath is a char * which i need for loading sound. Now i need the
> full path to the sound for loading. So
> remove all after the last / but add sounds/ban.wav.
> Something's wrong below.
> Many thanks again
> Michael
>
>
> std:: string s = filepath;
> std::string t = s.substr(0, s.find_last_of('/') + 1);
A bit dangerous. What happens if there is no '/' in s?
Is an empty t intended?
> char *conv;
> conv = new char[t.length() +1];
> strcpy(conv, t.c_str());
> char str[255] = "sounds/BAN11.wav";
> strcat(conv, str);
> alutLoadWAVFile((ALbyte*) conv, &format, &data, &size, &freq, &loop);
These last 7 lines can be written easier as
t += "sounds/BAN11.wav";
alutLoadWAVFile((ALbyte*) t.c_str (), &format, &data, &size, &freq, &loop);
with the side effect that t has a different value at the end. If that is not what you want:
const string conv = t + "sounds/BAN11.wav";
alutLoadWAVFile((ALbyte*) conv.c_str (), &format, &data, &size, &freq, &loop);
|