   Understanding this perticual IF  statement......pls help
  if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)) {    printf("Could not initialize SDL: %s.\n", SDL_GetError());   exit(-1);can some one explain me the above lines..... please tell me how the statement inside the IF condition bracket gets executed.explain the whole thing please   
  It's pretty simple. Anything that evaluates to a value can be put inside the parenthesis for an if statement. The if statement calls SDL_Init() compares the result to -1 and if it is -1 executes the printf() and exit().   ;  thanks man I have understood now................   ;  That code is missing a end }maybe it would be easier for you to read like thisint test = SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);if (test == -1){printf("Could not initialize SDL: %s.\n", SDL_GetError());exit(-1);};  You can put anything into an if statement that can be interpreted as a value. You can even do things like object instantiation in an if statement or even as condition of a loop. Obviously you should not do that to ensure readybility of your code. But from a compiler's point of view its alright:// warning: do not try this at home or you end up screwing readbility of your codeAnyClass obj* = NULL;if ( (obj = new AnyClass) == 0){   throw std::bad_alloc;};Quote:Original post by WaterwalkerYou can put anything into an if statement that can be interpreted as a value. You can even do things like object instantiation in an if statement or even as condition of a loop. Obviously you should not do that to ensure readybility of your code. But from a compiler's point of view its alright:// warning: do not try this at home or you end up screwing readbility of your codeAnyClass obj* = NULL;if ( (obj = new AnyClass) == 0){   throw std::bad_alloc;}That if will never be executed.  new will throw bad_alloc on its own; it will not return 0 unless you pass in nothrow.   ;  Um ... right of course. So just replace calling new with a replace of calling your own createAnyClass() function that creates and initalizes an instances and catches possible exceptions to return 0 to keep the app alife in case of bad alloc ... for whatever good you could do [grin]It should just illustrate that you can place virtually anything inside the if statement but thanks for pointing out.   ;  Also, take a look at:http://www.libsdl.org/docs.phpThe documentation may tell you what the return values mean.(-1 is usually used as an error value);  If you type just:SDL_Init(SDL_INIT_VIDEO)and something goes wrong and the video cant load, it returns a -1 according to the SDL Documentation.By putting it in an if statement:if(SDL_Init(SDL_INIT_VIDEO)==-1)print errormessage;You are still executing it, your just saying "If something went wrong, it will equal -1 so print an error message. Also on a side note you can use:if(SDL_Init(SDL_INIT_EVERYTHING) == -1)to initialize all SDL subsystems. I don't know of a drawback to this method but then again I'm still learning :)EDIT: Oops! I didn't realize this tab was open so long and that 3402830498 people replied already :D   ;  OOPS!!!! This post was supposed to go elsewhere! Sorry OP I wasn't hijacking your thread I typed in the wrong box :/[Edited by - Chrono1081 on June 14, 2009 2:26:18 AM]