查找两点之间的距离时出现编译错误

时间:2019-07-20 11:28:37

标签: c visual-studio scanf

编译错误

prog.c: In function ‘main’:
prog.c:8:2: warning: implicit declaration of function ‘scanf_s’ [-Wimplicit-function-declaration]
scanf_s("%f,%f,%f,%f", &x1, &x2, &y1, &y2);
  ^~~~~~~
/home/BRBLqY/cc0ysGb4.o: In function `main':
prog.c:(.text.startup+0x30): undefined reference to `scanf_s'
collect2: error: ld returned 1 exit status

代码

#include<stdio.h>
#include<math.h>

int main()
{
float x1, x2, y1, y2,D;
printf("\nEnter values of x1,x2,y1,y2");
scanf_s("%f,%f,%f,%f", &x1, &x2, &y1, &y2);
D = sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));

printf("\nThe distance is %f ", D);
return 0;


}

0 个答案:

没有答案