Notes 10 27 2014 Passing Arrays to Functions 1. When I want to pass an array to a function, I just use the name of the array. 2. The function declaration indicates that a parameter is an array by including [] in the name of the array. For Example printArray( myOutputFile, myArray, size ); Passing an Array Element to a Functions 1. Use the [] and an index value in the function call. For Example double angles[10]; for ( int i=0;i<10; i++ ) cout << sin( angles[i] ); Structs or Structure Data A struct is a way to bundle data together struct Data { int x; double y; void setX( int newx );//we can do this }; //<----notice they end with a ; Data myData; //this makes a variable of type Data myData.x = 10;//dot notation myData.y = 12.4; //this is a member function to setx void Data::setX( int newx ) { x = newx; } Arrays of Structs Data myArrayOfData[10]; for ( int i=0; i<10; i++ ) { myArrayOfData[i].x = i; myArrayOfData[i].y = i*1.0; //---or ---- these next 4 lines do exactly what the previous 2 do Data myData = myArrayOfData[i];//get myData out of the array myData.x = i; myData.y = i*1.0; myArrayOfData[i] = myData; //stuff myData back in the array }