944,124 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 12568
  • C RSS
Jul 13th, 2005
0

Problem passing structure with array into function

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
userlain is offline Offline
1 posts
since Jul 2005
Jul 13th, 2005
0

Re: Problem passing structure with array into function

For me there is no problem with this code actually.

Can you tell more about the problem you have ?
Reputation Points: 11
Solved Threads: 6
Junior Poster
CrazyDieter is offline Offline
106 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Program for gauge monitoring
Next Thread in C Forum Timeline: ofstream problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC