Beginner C/C++

Moderators: None (Apply to moderate this forum)
Number of threads: 5430
Number of posts: 16951

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Help with Structures and Pointers Posted by Engineria on 12 Aug 2012 at 3:26 PM
Hello Forum. I am a newby and trying to get some C code to compile for an embedded system using the Microchip C30 compiler. Whilst there are many examples of simple structures on the net, not all of these will compile in my environment, not sure if it is my code(C++ or C), compiler or simple mistakes.
Please could you advise me on the following code for a nested structure and some pointers. I cannot get it to compile!

struct channelStruct
{
unsigned long int sampleIndex;
int value;
}channelData,*channelDataPtr;


struct dataSetStruct
{
int channel;
struct channelData channelData;
} data, *dataPtr;

void dataStructInit()
{
//make first entry of sampleindex & value for each channel 0.
int i=1;

dataPtr=&data;

while (dataPtr->channel<=6)
{
dataPtr->channel=i;
channelDataPtr=&(dataPtr->channelData);
//I GET SYNTAX ERROR BEFORE '=' HERE!

channelDataPtr->channelData->sampleindex=0
channelDataPtr->channelData->value=0;
i++;

}
}



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.