J
Jeremy Beasley
I'm having a problem using pointers to structures. One method of declaring
point and then referencing a structure works, while the other generates an
error at compile time.
-----------------
ex1. (this method works)
struct data {
int a,b;
} myData;
struct data *p_data = &myData; /* define pointer and reference on
line */
--------------------------
ex2. (this method gives me a compile time error)
struct data {
int a,b;
} myData;
struct data *p_data; /* declare pointer of type data */
p_data = &myData; /* reference pointer to struct myData */
------------------------------
ex2. does the same thing as ex1. put just splits it apart on separate lines.
When compiling ex2., I get the following errors:
"conflicting types for 'p_data', previous declaration of 'p_data', data
definition has no type or storage class"
point and then referencing a structure works, while the other generates an
error at compile time.
-----------------
ex1. (this method works)
struct data {
int a,b;
} myData;
struct data *p_data = &myData; /* define pointer and reference on
line */
--------------------------
ex2. (this method gives me a compile time error)
struct data {
int a,b;
} myData;
struct data *p_data; /* declare pointer of type data */
p_data = &myData; /* reference pointer to struct myData */
------------------------------
ex2. does the same thing as ex1. put just splits it apart on separate lines.
When compiling ex2., I get the following errors:
"conflicting types for 'p_data', previous declaration of 'p_data', data
definition has no type or storage class"