|
|
box *mystruc
is exactly the same as writing box* mystruc
. When the function is declared before main there is no need to mention the name of the parameter. The only thing that is necessary here is the type of the parameter, box* (pointer to box).
#include <iostream> struct box { char maker[40]; float height; float width; float length; float volume; }; void value(box); void vol(box); using namespace std; int main() { box woodbox = { "Poad", 5.5, 10.0, 15.7, 0 }; vol(woodbox);//function call that passes the address of the woodbox array value(woodbox); return 0; } void value(box mystruc) { cout << "The maker of the box is " << mystruc.maker << ". " << endl; cout << "Height is " << mystruc.height << endl; cout << "Width is " << mystruc.width << endl; cout << "Length is " << mystruc.length << endl; cout << "Volume is " << mystruc.volume; } void vol(box mystruc) { mystruc.volume = mystruc.height * mystruc.width * mystruc.length; } |
|
|