Keil Logo

C51: ACCESSING A STRUCTURE VIA A POINTER


Information in this article applies to:

  • C51 Version 5.50

SYMPTOMS

If I declare a structure called foo then declare a pointer to foo called foo_ptr I am then able to access members of the structure via the pointer using the '.' operator. For example:

foo_ptr = &foo;    // initialize pointer to a structure

foo_ptr->x = 3;    // correct member accessing
foo_ptr.x = 3;     // this also works but it should generate an error

RESOLUTION

This is a known problem in C51 V5.x. It has been corrected in C51 V6.x (see below). If you still use C51 V5.x, care must be taken when accessing structures using pointers that the correct operator is used (->).

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Sunday, March 5, 2000


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.