11

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?

ildjarn
  • 62,044
  • 9
  • 127
  • 211
john
  • 147
  • 1
  • 7

1 Answers1

13

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

Kyle Jones
  • 5,492
  • 1
  • 21
  • 30