1. Define a struct type SDistance that contains two integer member, feet and inches.
2. Define a function that receives an array of SDistance and how many distances on the array as parameter. The function will ask input for feet and inches for each distance on the array.
3. Define another function that receives an array of SDistance and how many as parameter. The function will display each distance on the array without modifying their data.
4. Define yet another function that receives an array of SDistance and how many as parameter. The function will add all the distances and return the total. The inches value of the returned total should be less than 12. The function should not modify the distances stored on the array while adding them.
5. Write a driver program to test these functions described above.
I'm not asking for the code or anything like that , i just don't understand what i am supposed to be doing. Can anyone explain this easier?
void getArrayOfDates(SDate dates[], int size)
{
char ch;
for(int i = 0; i < size; ++i)
{
cout << "Enter a date in the format of mm/dd/yyyy: ";
cin >> dates[i].mm >> ch
>> dates[i].dd >> ch
>> dates[i].yy;
}
}
"size" is a parameter passed to the function, the value it has is given to the function when the function is called, so it can be different for each time the function is called.
In main, it looks like the function is called with size as 5.
constint ARR_SIZE = 10;
MyStruct structs[ARR_SIZE]; // An array of 10 MyStructs
// Assuming I'm calling my function from a couple of posts ago...
SomeFunc( structs, ARR_SIZE );
Well when you write the function itself you're not going to care about the size. You have the value you need as the argument named "size" and you can use that locally within the function.
You only need to worry about passing in the size value you need when you come to the final part: writing the "driver" code.
I think iHutch meant "client code" and not "driver code". "client code" is the code that uses the code you are writing. Even if your code and the client code are all in the same program, the distinguishment is still made.