SDL rectangle pointer error
This code compiles fine but the program crashes.
//global rectangles
SDL_Rect *player1, *player2, *credits, *exitt;
//function to set coords of rectangles
void SetRects(void)
{
cout << "in setrects" << endl;
player1->x = 1;
cout << "set player1.x" << endl;
player1->y = 1;
player1->w = 94;
player1->h = 26;
...
}
when i run this program (yes there is a lot more to it) i see the screen switch modes, and everything that comes before my call to the function SetRects(), but inside setrects the program crashes, i put in the cout statments to find the error and sure enough, i see the words "in setrects" but i never see the "set player1.x" part. What am I doing wrong in this code?