Jump to content
Sign in to follow this  
TomF

Struct Member As Index Into Array Fails

Recommended Posts

Hi-

 

Tried to use a member of a struct as an index into a string array. It doesnt work. See below;

 

struct sTimeDate
{
unsigned char day;
unsigned char month;
unsigned char year;
unsigned char hours;
unsigned char mins;
unsigned char secs;
};

void TransmitTimeDate(bool bTxTime, bool bTxDate, struct sTimeDate* ptd)
{
char* pszMonths[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};


unsigned char nMonth = ptd->month -1;

COMMS_TransmitText( pszMonths[nMonth] ); // OK

//  COMMS_TransmitText( pszMonths[(ptd->month)-1] );  // doesnt work
}

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×