So my now completed program works as intended apart from one crash that happens when i keypress 'p' which should only switch an if statement to the else part, however it crashes with the "illegal instruction (core dumped)" message.
#include <stdio.h>
// include the UFCFGL301's standard library
#include <ufcfgl-30-1.h>
// uncomment if you want to use the graphics library
#include <graphics.h>
const uint32 window_Width = 600;
const uint32 window_Height = 400;
using namespace uwe;
struct Rect{
  int x,y,width,height,r,g,b;
};
struct Circle{
  int x,y,radius,r,g,b;
};
union CircleorRect{
  Rect rect;
Circle circle;
};
Rect createRect() {
  int x = rand() % window_Width;
  int y = rand() % window_Height;
  int width = rand() % 200;
  int height = rand() % 200;
  int r = rand()%256;
  int g = rand()%256;
  int b = rand()%256;
  return Rect{x, y, width, height, r, g, b};
};
Circle createCirc() {
  int x = rand() % window_Width;
  int y = rand() % window_Height;
  int radius = rand() % 200;
  int r = rand()%256;
  int g = rand()%256;
  int b = rand()%256;
  return Circle{x, y, radius, r, g, b};
};
Rect createRect();
Circle createCirc();
int main(void) {
// graphics window
initialiseGraphics(window_Width,window_Height);
// variables
int count = 0,pressedcount;
Circle circle[1000];
Rect rects[1000];
bool stopCircs = false;
// creating distinct shapes then mapping them.
loop(
  [&](){
    rects[count] = createRect();
    //if circles = create new circle and paint it
    if (stopCircs == false) {
      circle[count] = createCirc();
      for (size_t i = 0; i < count; i++) {
        setColour(circle[i].r,circle[i].g,circle[i].b);
        drawFilledCircle(circle[i].x,circle[i].y,circle[i].radius);
      }
    }
    else {
      for (size_t i = 0; i < pressedcount; i++) {
        setColour(circle[i].r,circle[i].g,circle[i].b);
        drawFilledCircle(circle[i].x,circle[i].y,circle[i].radius);
      }}
    for (size_t i = 0; i < count; i++) {
      setColour(rects[i].r,rects[i].g,rects[i].b);
      drawFilledRect(rects[i].x,rects[i].y,rects[i].width,rects[i].height);
    }
      count++;
      if (count >= 1000) {
        count = 0;
      }
  },
  [&](KeyPress keyPress){
    if (getTextCharacter(keyPress) == 'q') {
      return true;
    }
    else if (getTextCharacter(keyPress) == 'p') {
      stopCircs = true;
      pressedcount = count;
    }
    else {
      return false;
    }
  });
return 0;
}
The 'p' press should only switch from generating new circles to just loading the older ones, no idea why it causes a crash. This is the whole thing so if anyone wants to try and run it or tell me how to get a better debugger than trying and failing any help would be appreciated.
 
    