Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / using variable with dbLoadImage

Author
Message
Xzod
15
Years of Service
User Offline
Joined: 21st Jan 2009
Location:
Posted: 28th Jan 2009 20:32
hello

i'm kind learning c++ and new to it, for a code like :

dbLoadImage("my_image.jpg", 1);

instead of using "my_image.jpg"i want to use a varibale, like :

char c_imageName[100];
c_imageName = "my_image.jpg"
dbLoadImage(c_imageName , 1);

but this code won't compile, it returns error "can't convert const char[18] in char[100]"

the help give : void dbLoadImage ( char* szFilename, int iImage )

so how to use a variable to give it a filename to load ?

thanks for helping
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 28th Jan 2009 21:28
You can't assign a char array the value of a string literal that way except at the time of declaration. You can either do

char c_imageName[100] = "my_image.jpg";

or

char c_imageName[100];
strcpy (c_imageName, "my_image.jpg");

You'll need to include the "string.h" header for the latter.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Xzod
15
Years of Service
User Offline
Joined: 21st Jan 2009
Location:
Posted: 28th Jan 2009 23:15
thank you, that work fine

Login to post a reply

Server time is: 2024-11-25 13:53:56
Your offset time is: 2024-11-25 13:53:56