Updated code.
Code:
#include <stdio.h>
#include <math.h>
#ifndef PI
#define PI 3.14159265359
#endif
typedef struct point { double x, y; } point;
double getAngleBetween(point p1, point p2)
{
double x = p2.x - p1.x, y = p2.y - p1.y;
double angle = asin(y / sqrt(x * x + y * y)) * (180 / PI);
angle = x < 0 ? angle - 90 : 90 - angle;
return angle < 0 ? angle + 360 : angle;
}
int main()
{
while (1) // ctrl-c (or eof) to quit
{
point p1, p2;
printf("Enter two points: ");
if (scanf("%lf%lf%lf%lf", &p1.x, &p1.y, &p2.x, &p2.y) != 4)
break;
printf("%.3f\n", getAngleBetween(p1, p2));
}
return 0;
}