How to declare at beginning of program
In the listing below, an attempt to declare the rectangle "r" before the main() function is called results in an error. error: 'r' does not name a type r.x = 150;<br> Why must "r" be declared after main()? #include <SDL2/SDL.h> int main (int argc, char** argv) { // Creat a rect at pos ( 50, 50 ) that's 50 pixels wide and 50 pixels high. SDL_Rect r; r.x = 150; r.y = 150; r.w = 200; r.h = 100; SDL_Window* window = NULL; window = SDL_CreateWindow ("SDL2 rectangle", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN ); // Setup renderer SDL_Renderer* renderer = NULL;