I am attempting to read a random image out of a directory using gdi+. I am attempting to do it by building a vector of all the files in the directory, then choose a random item out of that vector and use that to read the image. I can build the list of the files, using a while loop with push_back. This gives a vector of strings. However the Image class of gdi+ does not accept strings, only wchar*.
I will spare you the entirety of the code, as it is a bit of a mess at the moment, but here is the relevant parts.
struct dirent *dir;
int i =0;
while ((dir=readdir(d)) != NULL)
// cout << dirlist[i-1] << endl;
Image image(L"photo.jpg"); // obviously this needs to be changed, I just haven't done it yet.
I attempted to convert the string into a wstring, and then use .c_str() to convert it into wchar, but I am recieving errors relating to differing levels of indirection. I am wondering if there is a different way of doing it, that doesn't involve converting from string to wchar? Or a different way all together. I'm trying to keep the program as small as possible, so I would prefer to not use Boost. I am currently using dirent.h.