error : expected identifier or '(' before 'struct'
Bonjour,
Je vous remercie par avance.
J'apprends le C à l'Université mais j'ai manqué plusieurs cours pour raison de santé. J'ai un support de cours qui n'indique pas particulièrement de mettre "(" avant "struct"
aussi j'ai du mal à comprendre ce message d'erreur. Comme vous pouvez sûrement le deviner le but est de créer un programme pour faire des opérations sur des nombres complexes en nous incitant à utiliser les fonctions.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <complex.h>
typedef struct
{
float re;
float im;
};
Complex;
typedef struct
{
float re;
float im;
};
Complex_z1;
typedef struct
{
float re;
float im;
};
Complex_z2;
struct Complex(struct Complex_z1, struct Complex_z2)
{
float a=2.000000;
float b=1.000000;
float Complex.re=float Complex_z1.re+float Complex_z2.re;
float Complex.im=float Complex_z1.im+float Complex_z2.im;
return Complex;
}
struct complex_sous(struct complex z1, struct complex z2)
{
complex.re=complex z1.re-complex z2.re;
complex.im=complex z1.im-complex z2.im;
return complex;
}
struct complex_mul(complex z1, complex z2)
{
complex.re=complex z1.re*complex z2.re;
complex.im=complex z1.im*complex z2.im;
return complex;
}
float c_mod(complex);
{
return pow((pow(re,2)+pow(im,2)), 0.5);
}
struct complex_conj(complex)
{
complex.re=complex z1.re+complex z2.re;
complex.im=-complex z1.im-complex z2.im;
return complex;
}
struct complex_div(complex z1, complex z2)
{
complex.re=complex z1.re/complex z2.re;
complex.im=complex z1.im/complex z2.im;
return complex;
}
float c_arg(complex)
{
return atan(complex.im/complex.re);
}
int main(void)
{
float a=2.000000;
float b=1.000000;
Complex_add(a, b);
printf("%f", add);
return 0;
} |