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 CCS Technical Support

Pass a struct to function

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



Joined: 13 Dec 2004
Posts: 7

View user's profile Send private message Yahoo Messenger MSN Messenger

Pass a struct to function
PostPosted: Tue Dec 21, 2004 11:50 pm     Reply with quote

Hello ... I am trying to pass a struct to a function like this

Code:


typedef struct
{
   float longitude;         // logitude in degree /min/ sec
   float latitude;          // latitude in degree / min /sec
   float height;            // height of the antenna in degree
   BOOLEAN valid;
}raw_coord;



Code:
 

void get_data(raw_coord)
{
         // some code here
         raw_coord->longitude = 1.0;
}




and I get the following error :
previous identifier must be a pointer

I also have tried this

Code:

// normal c / c++
void get_data(raw_coord * x)
{
     x->longitude = 1.0;
}


but the compiler did not like it

Is it possible to pass a struct (by reference) to a function with this compiler ?

please help ... I am getting insane

Thank you in adnvance

mp3fusion
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Wed Dec 22, 2004 12:16 am     Reply with quote

How about


Code:
void get_data(struct raw_coord * x)
{
     x->longitude = 1.0;
}



or


Code:
void get_data(struct raw_coord x)
{
     x.longitude = 1.0;
}
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