I need my code to terminate when a word such as "exit" is typed into the first data input. I do not know that proper function or method to achieve this. My data is correct just need to terminate with a word command. Please any advice or tips with explanation would be greatly appreciated.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void) {
double xminA, xmaxA, yminA, ymaxA, xminB, xmaxB, yminB, ymaxB;
double xminC, xmaxC, yminC, ymaxC;
char end;
while(1){
printf("Rectangle A:");
scanf("%lf%lf%lf%lf", &xminA, &yminA, &xmaxA, &ymaxA);
printf("Rectangle B:");
scanf("%lf%lf%lf%lf", &xminB, &yminB, &xmaxB, &ymaxB);
if(xminA>xmaxB || xminB>xmaxA || yminA>ymaxB || yminB>ymaxA){
printf("No overlapping area\n");
}
else if(xminA<=xmaxB || xminB<=xmaxA || yminA<=ymaxB || yminB<=ymaxA){
xminC= fmax(xminA,xminB);
xmaxC= fmin(xmaxA, xmaxB);
yminC= fmax(yminA, yminB);
ymaxC= fmin(ymaxA, ymaxB);
printf("Overlap rectangle: (%lf,%lf) (%lf,%lf)\n", xminC, yminC, xmaxC, ymaxC);
}
}
return EXIT_SUCCESS;
}
scanffgetsis deprecated": What?! No. You meangets()right?