CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem pointing into a structure

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jerrybrowse



Joined: 17 Sep 2003
Posts: 2
Location: Herts. UK

View user's profile Send private message

Problem pointing into a structure
PostPosted: Fri May 20, 2005 9:25 am     Reply with quote

I have a problem accessing data within a structure. The structure is:

Code:
struct maxfio
{
    int max_rcv[32];
    int *p_rcv;
    int rcv_chksm;
} maxfcb[4];


max_rcv is a buffer for serial data coming in.
*p_rcv is the pointer to access it.

Assuming dbyte is an int8 and block is an int8, and the pointer is correctly
set, I use the following that works:

Code:
    dbyte=*(maxfcb[0].p_rcv)++;            // hard maxfcb index reference


However, if I use a variable, 'block', whose value is 0 thus:

Code:
    dbyte=*(maxfcb[block].p_rcv)++;     // varible maxfcb index reference


this does not work.

Is this incorrect syntax or is the compiler confused?
mike holeton
Guest







PostPosted: Fri May 20, 2005 9:36 am     Reply with quote

Have you defined block any where? int, char, etc. I think the compiler is confussed, because it does not know what block is.
jerrybrowse



Joined: 17 Sep 2003
Posts: 2
Location: Herts. UK

View user's profile Send private message

PostPosted: Fri May 20, 2005 9:41 am     Reply with quote

Thanks for the reply Mike.

No, I'm afraid block is defined (as an int8) and is set to a value which in this case is zero (hex).

Regards
Jerry
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group