954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem passing structure with array into function

The structure:

typedef struct{
     int val[256];
}values;


The function(needs to pass information into the structure array 'val'):

void changeval(values *obj, int v, int a){
     (*obj).val[v]=a;
}

^^That piece is the piece I am having issues with...


And finally, the call:

int main(){
     values item;
     changeval(&item,0,50);
     return 0;
}


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? :sad:

userlain
Newbie Poster
1 post since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

For me there is no problem with this code actually.

Can you tell more about the problem you have ?

CrazyDieter
Junior Poster
108 posts since Jul 2005
Reputation Points: 11
Solved Threads: 6
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You