Question

i have a very simple question...

i am using the SDL API which was written in C. i am using C++. my compiler supports the keyword nullptr, and I've been reading up on it. it seems as if it is better to use rather than using the NULL macro.

when I call SDL_SetVideoMode, I assume it returns NULL on failure, so if i do:

SDL_Surface *test = nullptr;

if ((test = SDL_SetVideoMode(params)) == nullptr)
{
    // to-do code
}

will this accurately check if my optimization on the surface test was successful?

Was it helpful?

Solution

Yes. nullptr is comparable to and equivalent to a null pointer of any other pointer type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top