Problem passing structure with array into function

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

Join Date: Jul 2005
Posts: 1
Reputation: userlain is an unknown quantity at this point 
Solved Threads: 0
userlain userlain is offline Offline
Newbie Poster

Problem passing structure with array into function

 
0
  #1
Jul 13th, 2005
The structure:
  1. typedef struct{
  2. int val[256];
  3. }values;

The function(needs to pass information into the structure array 'val'):
  1. void changeval(values *obj, int v, int a){
  2. (*obj).val[v]=a;
  3. }
^^That piece is the piece I am having issues with...


And finally, the call:
  1. int main(){
  2. values item;
  3. changeval(&item,0,50);
  4. return 0;
  5. }



Ok, why can't I pass a user-defined datatype into a function and be able to access the array that is in the object?
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 76
Reputation: CrazyDieter is an unknown quantity at this point 
Solved Threads: 3
CrazyDieter's Avatar
CrazyDieter CrazyDieter is offline Offline
Junior Poster in Training

Re: Problem passing structure with array into function

 
0
  #2
Jul 13th, 2005
For me there is no problem with this code actually.

Can you tell more about the problem you have ?
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC