pass a structure as reference parameter.

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 35
Reputation: CoolAtt is an unknown quantity at this point 
Solved Threads: 0
CoolAtt's Avatar
CoolAtt CoolAtt is offline Offline
Light Poster

pass a structure as reference parameter.

 
0
  #1
Dec 16th, 2008
plz explain how to do this the proper way.

  1. main.c
  2. =====
  3. struct names{ // definitions
  4. -----
  5. ----
  6. ----
  7. }
  8.  
  9. struct names x;
  10.  
  11. function1(&x);
  12.  
  13. file2.c
  14. ======
  15. function1(struct names *x){
  16. ----
  17. ----
  18. ----
  19.  
  20. }

am getting warning: 'struct names' declared inside parameter list
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: pass a structure as reference parameter.

 
0
  #2
Dec 16th, 2008
I guess it's
  1. struct names{
  2. // ....
  3. } x;

or put it this way
  1. struct names{
  2. // ...
  3. };
  4.  
  5. struct names x;
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 35
Reputation: CoolAtt is an unknown quantity at this point 
Solved Threads: 0
CoolAtt's Avatar
CoolAtt CoolAtt is offline Offline
Light Poster

Re: pass a structure as reference parameter.

 
0
  #3
Dec 16th, 2008
about the warning am saying. any idea ?
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 148
Reputation: devnar will become famous soon enough devnar will become famous soon enough 
Solved Threads: 16
devnar's Avatar
devnar devnar is offline Offline
Junior Poster

Re: pass a structure as reference parameter.

 
0
  #4
Dec 16th, 2008
You're missing a semi-colon after defining the struct.

Should be:
struct names{  // definitions
-----
----
----
};
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 35
Reputation: CoolAtt is an unknown quantity at this point 
Solved Threads: 0
CoolAtt's Avatar
CoolAtt CoolAtt is offline Offline
Light Poster

Re: pass a structure as reference parameter.

 
0
  #5
Dec 16th, 2008
its not that i think. i had put a semi-colon there.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: pass a structure as reference parameter.

 
0
  #6
Dec 16th, 2008
It's a good time to remember header files. Place the structure definition in .h file then include it in both main.c and file2.c. Now you have common structure (and other types) definition source.
A compiler knows nothing about main.c contents when processes file2.c.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1457 | Replies: 5
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC