Habe folgenden Code:
Code: Alles auswählen
#include <stdio.h>
int scheitelhoehe(struct parabel p, double *y)
{
// p(x) = a*x^2 + b*x + c
int rc = 0;
if ((p.a)==0)
{
return rc = 1;
}
else
{
*y = p.c - ((p.b*p.b) / (4*p.a));
return rc;
}
}
void sort_parabeln(struct parabel *p, int n)
{
int i, j;
double y1, y2;
struct parabel x;
for (i = 0; i < n - 1; i++){
if (scheitelhoehe(p[i+1], &y2)==0){
if(scheitelhoehe(p[i], &y1)==1){
x = p[i+1];
p[i+1] = p[i];
p[i] = x;
i = 0;
}else{
if(y2 < y1){
x = p[i+1];
p[i+1] = p[i];
p[i] = x;
i = 0;
}
}
}
}
}
int main() {
struct parabel p[] = {
{1,2,3}, // 2
{2,5,-19}, //-22
{0,0,0},
{-1,0,0} // 0
};
double y;
printf("Index 1 ist eine echte Parabel: %d\n", scheitelhoehe(p[0], &y) == 0);
sort_parabeln(p, sizeof(p) / sizeof(struct parabel));
return 0;
}

4 [Warning] "struct parabel" declared inside parameter list
4 [Warning] its scope is only this definition or declaration, which is probably not what you want
5 parameter `p' has incomplete type
23 [Warning] "struct parabel" declared inside parameter list
28 storage size of 'x' isn't known
31 invalid use of undefined type `struct parabel'
31 invalid use of undefined type `struct parabel'
31 pointer to incomplete type
32 invalid use of undefined type `struct parabel'
32 dereferencing pointer to incomplete type
33 invalid use of undefined type `struct parabel'
33 invalid use of undefined type `struct parabel'
33 dereferencing pointer to incomplete type
34 invalid use of undefined type `struct parabel'
34 invalid use of undefined type `struct parabel'
34 dereferencing pointer to incomplete type
34 invalid use of undefined type `struct parabel'
34 dereferencing pointer to incomplete type
35 invalid use of undefined type `struct parabel'
35 dereferencing pointer to incomplete type
39 invalid use of undefined type `struct parabel'
39 invalid use of undefined type `struct parabel'
39 dereferencing pointer to incomplete type
40 invalid use of undefined type `struct parabel'
40 invalid use of undefined type `struct parabel'
40 dereferencing pointer to incomplete type
40 invalid use of undefined type `struct parabel'
40 dereferencing pointer to incomplete type
41 invalid use of undefined type `struct parabel'
41 dereferencing pointer to incomplete type
51 elements of array `p' have incomplete type
53 [Warning] excess elements in struct initializer
53 [Warning] (near initialization for `p[0]')
53 [Warning] excess elements in struct initializer
53 [Warning] (near initialization for `p[0]')
53 [Warning] excess elements in struct initializer
53 [Warning] (near initialization for `p[0]')
55 [Warning] excess elements in struct initializer
55 [Warning] (near initialization for `p[1]')
55 [Warning] excess elements in struct initializer
55 [Warning] (near initialization for `p[1]')
55 [Warning] excess elements in struct initializer
55 [Warning] (near initialization for `p[1]')
57 [Warning] excess elements in struct initializer
57 [Warning] (near initialization for `p[2]')
57 [Warning] excess elements in struct initializer
57 [Warning] (near initialization for `p[2]')
57 [Warning] excess elements in struct initializer
57 [Warning] (near initialization for `p[2]')
59 [Warning] excess elements in struct initializer
59 [Warning] (near initialization for `p[3]')
59 [Warning] excess elements in struct initializer
59 [Warning] (near initialization for `p[3]')
59 [Warning] excess elements in struct initializer
59 [Warning] (near initialization for `p[3]')
51 array size missing in 'p'
51 storage size of 'p' isn't known
66 invalid application of `sizeof' to incomplete type `parabel'
66 [Warning] division by zero
Es sind ja ziemlich viele gleiche Meldungen dabei aber wie löse ich die?