Re: structures....
- From: "Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx>
- Date: Tue, 17 Jun 2008 09:35:39 -0500
Robby wrote:
Hello QbProg and Drew,
I declared the
struct INPUT *z;
in the API.h file instead of the ACM152.h file. When this line of
code was declared in the ACM152.h file, the compiler did not see it
and so at compile time it generated the errors above. Now the program
compiles. Thankyou for your feedback !
Well it shouldn't be working. You're not using the name "INPUT"
consistently. In one place it's a struct tag, in another it's a typedef.
Be consistent (and I'm not sure you can forward typedef a struct the way you
can forward declare it, I would always include the header that defines the
struct and typedef first unless you have a really good reason not to).
=======================ACM152.h
struct INPUT *z;
int _a,_b,_c,_d,_e;
long _l;
...
INPUT z = API_config_MENU(); //ERROR HERE: EXPECTING A VARIABLEYou already declared z as INPUT *z in the h file.
So a simple
z = API_config_MENU(); would be sufficient.
also
INPUT * z = API_config_MENU();
would be ok, but you'd get a "redeclaration" error.
_a=z->DRAW_FAR_X; //ERROR HERE: ELEMENT IS NOT A MEMBER
_b=z->DRAW_FAR_Y; //ERROR HERE: ELEMENT IS NOT A MEMBER
_c=z->DRAW_LEAST_X; //ERROR HERE: ELEMENT IS NOT A MEMBER
_d=z->DRAW_LEAST_Y; //ERROR HERE: ELEMENT IS NOT A MEMBER
_l=z->MSG_NUM; //ERROR HERE: ELEMENT IS NOT A MEMBER
_e=z->SYMBOL_INTERVAL; //ERROR HERE: ELEMENT IS NOT A MEMBER
If you declare z as INPUT * this code is ok. If you declare z as
INPUT it is not , because you are using -> with a struct var (not a
pointer).
Also, remember to "free" z when you have done.
Bye
QbProg
.
- References:
- Re: structures....
- From: QbProg
- Re: structures....
- From: Robby
- Re: structures....
- Prev by Date: Re: get last char in a string
- Next by Date: Re: Bypass print request
- Previous by thread: Re: structures....
- Next by thread: unsigned long long to string
- Index(es):
Relevant Pages
|