Putting a varible for a file name
390 C:\Dev-Cpp\animation\main.cpp initializing argument 2 of `IDirectDrawSurface7* DDLoadBitmap(IDirectDraw7*, const CHAR*, int, int)'
g_pddsone = DDLoadBitmap(g_pdd,"image.bmp",0,0);
How can I change "image.bmp to a varible?
This way:
std::string fileName("test.bmp");g_pddsone = DDLoadBitmap(g_pdd,fileName.c_str(),0,0);
jfclavette forgot to say that you need to #include <string>.
Another option, if you don't want to use STL is
char* fileName = "test.bmp";
g_pddsone = DDLoadBitmap(g_pdd,fileName,0,0);
Another option, if you don't want to use STL is
char* fileName = "test.bmp";
g_pddsone = DDLoadBitmap(g_pdd,fileName,0,0);
There shouldn't be a problem passing a string literal for a *const* char*. What exactly are you doing here (please show the surrounding code, and the exact, *full* error message)?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement