Devo resolver o seguinte problema criando uma funcão para leitura, uma para cálculo e utilizar ponteiros.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
struct ponto
{
int x;
int y;
}ponto1, ponto2;
struct ponto *p1, *p2;
p1 = &ponto1;
p2 = &ponto2;
void ler(struct ponto *p1, *p2)
{
printf("Digite o valor de X1: ");
fflush(stdin);
scanf("%d", &p1 -> x);
printf("Digite o valor de Y1: ");
fflush(stdin);
scanf("%d", &p1 -> y);
printf("Digite o valor de X1: ");
fflush(stdin);
scanf("%d", &p2 -> x);
printf("Digite o valor de Y1: ");
fflush(stdin);
scanf("%d", &p2 -> y);
}
int calculo(struct ponto *p1, *p2)
{
int a, b, d;
a = (*p1).x - (*p2).x;
b = (*p1).y - (*p2).y;
d = sqrt(pow(a,2)+pow(b,2));
printf("%d", d);
}
int main()
{
ler(struct ponto *p1, *p2);
calculo(struct ponto *p1, *p2);
return 0;
}
porém eu já tentei de tantas maneiras diferentes e continua apresentando os mesmos erros. São eles;
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
|11|warning: data definition has no type or storage class|
|11|warning: type defaults to 'int' in declaration of 'p1' [-Wimplicit-int]|
|11|error: conflicting types for 'p1'|
|10|note: previous declaration of 'p1' was here|
|11|warning: initialization makes integer from pointer without a cast [-Wint-conversion]|
|12|warning: data definition has no type or storage class|
|12|warning: type defaults to 'int' in declaration of 'p2' [-Wimplicit-int]|
|12|error: conflicting types for 'p2'|
|10|note: previous declaration of 'p2' was here|
|12|warning: initialization makes integer from pointer without a cast [-Wint-conversion]|
|14|error: expected declaration specifiers or '...' before '*' token|
|30|error: expected declaration specifiers or '...' before '*' token|
||In function 'main':|
|43|warning: implicit declaration of function 'ler' [-Wimplicit-function-declaration]|
|43|error: expected expression before 'struct'|
|44|warning: implicit declaration of function 'calculo' [-Wimplicit-function-declaration]|
|44|error: expected expression before 'struct'|
||=== Build failed: 6 error(s), 8 warning(s) (0 minute(s), 0 second(s)) ===|