構造体を使って、点と点の距離をもとめるプログラムを分割コンパイルする課題をしているのですが、メインも関数もエラーが出てしまって、どうしてそのようなエラーがでているのかわからなくて質問させていただきました。
/main/
#include <stdio.h>
#include "dist4.h"
#define REPEAT 3
int main(void)
{
point_t p1, p2;
int r;
for (r=0; r<REPEAT; r++) {
fprintf(stderr, "p1 と p2 の座標 (それぞれ x と y) をスペース区切りで : ");
scanf("%lf %lf", &p1.x, &p1.y);
fprintf(stderr, "p2 の座標 (x と y): ");
scanf("%lf %lf", &p2.x, &p2.y);
printf("%0.4f\n", dist(p1,p2));
}
return 0;
}
/関数/
#include<stdio.h>
#include<math.h>
#include"dist.h"
double dist(point_t p1,point_t p2)
{
double dist,dx,dy;
dx=p2.x-p1.x;
dy=p2.y-p1.y;
dist=sqrt(dxdx+dydy);
return dist;
}
/定義/
typedef struct {
double x; /* x座標 /
double y; / y座標 */
} point_t;
double dist(point_t p1,point_t p2);
です。
よろしくお願いします><
回答1件
あなたの回答
tips
プレビュー