I am writing a simple program to add two complex number using struct. All goes well except that when printing the values, I get an error that I am dereferencing an incomplete pointer.
Here is the code:
struct complexNumber * n1 = (struct complexNumber *) createNumber(10,10);
struct complexNumber * n2 = (struct complexNumber *) createNumber(03,12);
struct complexNumber * n3 = (struct complexNumber *) addComplexNunbers(n1,n2);
printf("Real Part: %d Imaginary Part: %d",n3->real,n3->imaginary);
您需要include
标头fine,它定义了struct complexNumber
。
The whole point of using incomplete type is to make the program able to use a pointer to an object, without knowing the implementation of said object.
Therefore, it never makes any sense to access the pointed-to contents of an incomplete type.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.