I was wondering if there's a way to pass individual structure array elements to a function without using pointers. Im having some trouble with it.
I was wondering if there's a way to pass individual structure array elements to a function without using pointers. Im having some trouble with it.
By value? So that you're just getting the value of the data contained? Sure:
Quzah.Code:struct mystruct { int x; }; struct mystruct myarray[5]; void myfun( int someInt ) { do_something( someInt ); } To call this function and only pass it 'x', do: myfun( myarray[someValue].x ); An array of pointers to structures, you'd change it to: myfun( myArray[someValue]->x );
Hope is the first step on the road to disappointment.