| | |
Problem passing structure with array into function
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2005
Posts: 1
Reputation:
Solved Threads: 0
The structure:
The function(needs to pass information into the structure array 'val'):
^^That piece is the piece I am having issues with...
And finally, the call:
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?
C Syntax (Toggle Plain Text)
typedef struct{ int val[256]; }values;
The function(needs to pass information into the structure array 'val'):
C Syntax (Toggle Plain Text)
void changeval(values *obj, int v, int a){ (*obj).val[v]=a; }
And finally, the call:
C Syntax (Toggle Plain Text)
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?
![]() |
Similar Threads
- Passing 2D Array of Pointers into a function (C++)
- Help with 1.pointers and 2.error checking (C++)
- passing the recordset data into an Array (ASP)
- problem in passing multiple checkbox values (ASP)
- Segmentation Fault (C++)
- Passing array of structures into a function (C++)
- structures containing a pointer to an array (C++)
Other Threads in the C Forum
- Previous Thread: Program for gauge monitoring
- Next Thread: Qt4 and devcpp
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory drawing dynamic executable fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o inches infiniteloop initialization interest kilometer km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape socketprograming spoonfeeding stack standard strchr string strings structures student suggestions system systemcall test testautomation unix user voidmain() wab win32api windows.h





