Putting a varible for a file name

Started by
3 comments, last by Zahlman 18 years, 6 months ago
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?
Advertisement
This way:

std::string fileName("test.bmp");g_pddsone = DDLoadBitmap(g_pdd,fileName.c_str(),0,0);
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
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);
thanx for sharing
Do, though, use the STL.
[ search: google ][ programming: msdn | boost | opengl ][ languages: nihongo ]
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