Hello, I am a newbie to C programming, so forgive me if the questions I ask sound stupid.
I am trying to create a program to calculate complex numbers using structures.
I want to pass the value of the structure into the function and let the user change the value of the numbers. However, I keep getting this message:
The left hand argument of '.' must be a structure not '<ptr>complex'.
I have looked at some reference books, but i am still stumped on how to change the value of the structure in the function. Below is the code
<code>
#include <stdio.h>
typedef struct complex{
int real;
int imaginary;
};
void take_values(complex *A);
int main(void)
{
complex A;
take_values(&A);
printf("You have typed %d + j%d ", A.real,A.imaginary);
return(0);
}
void take_values(complex *A)
{
printf("Please enter the real part of complex number, A: ");
scanf("%d", A.real);
printf("Please enter the imaginary part of complex number, B: ");
scanf("%d",A.imaginary);
}
</code>