Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/19/03 10:06
Read: times


 
#43755 - RE: Pointers to Structure Elements
Responding to: ???'s previous message
" would prefer to simply start at the top of the structure and have a pointer to each element"

Really, you don't want your serial driver to have any knowledge at all of the data structure - all it knows is to receive bytes and put them, in order, into a buffer.
The fact that the rest of your code accesses this data as a structure should be of no concern whatsoever to your serial driver.

So, all you need to do is give your serial driver the address where it is to start writing the data; ie, the start address of the structure - which simply means using the standard 'C' address of operator, '&' (ampersand)

Your driver then writes to successive bytes either by incrementing the pointer, or using the 'C' pointer-offset operator, "[]" (square brackets).

You should also tell the driver the size of the buffer (structure) - so that it can prevent overrun!

Alternatively, you could use a union consisting of your structure and a char array.


List of 12 messages in thread
TopicAuthorDate
Pointers to Structure Elements            01/01/70 00:00      
   RE: Pointers to Structure Elements            01/01/70 00:00      
   RE: Pointers to Structure Elements            01/01/70 00:00      
   RE: Pointers to Structure Elements            01/01/70 00:00      
      RE: Pointers to Structure Elements            01/01/70 00:00      
   RE: Pointers to Structure Elements            01/01/70 00:00      
      RE: Pointers to Structure Elements            01/01/70 00:00      
         RE: Pointers to Structure Elements            01/01/70 00:00      
   RE: Pointers to Structure Elements            01/01/70 00:00      
   RE: Pointers to Structure Elements            01/01/70 00:00      
   Universal casting to structs/union/void            01/01/70 00:00      
      RE: Universal casting to structs/union/void            01/01/70 00:00      

Back to Subject List