I'm still quite a beginner with C++ (or any programming), but I thought I'd take a bit of a break from the everyday learning of boring data types, operations 'n stuff, so I tried SDL just a little bit.
I tried to make a program that draws random rectangles all over the screen.
Hmm, interesting. I wouldn't though the line SDL_Rect randRect[] = {(halfscreenX - (rand() % halfscreenX)), (halfscreenY - (rand() % halfscreenY)), (rand() % halfscreenX), (rand() % halfscreenY)};
compiles, but it does. It simply creates an array of size 1.
Anyway, what you're doing wrong is accessing nonexistant elements of randRect[].