Compass for selfparking car

Hello, i have Arduino robot wich has a compass. i make selfparking car with 4 IR sensors but i want to use the compass with parking. so i can read the value from compass but I want to stop the robot after it has driven 45 degrees. but i can't know how i programm that. i wrote simple code to understand what i want.

// include the robot library
#include <ArduinoRobot.h>
#include <Wire.h>



int compassValue;
int direc = 180; 

void setup() {
  
  Robot.begin();
  
}

void loop() {

    Robot.motorsWrite(-100, -50); // Robot  goes back with  45 degrees
  // read the compass orientation
  compassValue = Robot.compassRead();
  // mybe its 90 or 180 that depends on the direction

  // how many degrees are we off
  int diff = direc - compassValue;

  if( diff == 45)
  {
    Robot.motorsStop();
  }
 
}

First make sure that your compass is properly calibrated while mounted in the robot (tutorial here) and that it works properly for all compass directions.

In order to turn 45 degrees, the robot first determines the direction it is currently headed, then it turns until the compass reads 45 degrees away from that first heading.

thank you for your help.
the compass work very well. wenn i start the robot in diffrent direction the angle will be between 0 und 360 degree.
in another words i need a code wich can save the first reading from the compass !!
do you know how?

int x = compass_read();
int diff = compass_read() - x;

Thank you very much. i needes static int. so i solved it.

compassValue = Robot.compassRead();
 static int x  = compassValue;

 
  int diff = compassValue - x;
 
 
  if (diff == -45) {
   Serial.println("it turns 45 degrees");
  }