Hello,
I am trying to work with SDL and one of their functions takes a char * file as a function a parameter. However, i'm running into trouble how to actually set this variable in my constructor.

I am getting a problem where if I use a pointer to a char and set it as "test.bmp" I get an error stating "cannot implicitly convert expression (file) of type string to char*. After that I decided to try to set file to 'test.bmp' instead, and in that case I get: "Unterminated character constant" . Although I am familiar with what this error is referring to, I do not know how to add a terminator in D.

This is the function that I intend to use the filename in:
**Note the function LoadBMP is the one that REQUIRES a pointer to a char
--------------------------------------
        SDL_Surface * Load(char * file)
        {
                SDL_Surface * Temp = null;

                if((Temp = SDL_LoadBMP(file)) == null)
                        return null;

                Surface = SDLDisplayFormat(Temp);

                SDL_FreeSurface(Temp);

                return Surface;
        }
----------------------------------------

This is the constructor that is giving me the error:
----------------------------------------------------------
        char * file;
        
        this()
        {
                this.filename = "test.bmp";
        }
-------------------------------------------------------------


Reply via email to