Hello,
I am still working on the self study thing. I have decided to do or attempt to do a project that requires a header files with 2 other source files. The header file was given in the book. It is as follows:
#ifndef GOLF_H_
#define GOLF_H_
//golf.h -- for pe9-1.cpp
const int Len=40;
struct golf
{
char fullname[Len];
int handicap;
};
// function sets golf structure to provided name, handicap
// using values passed as arguments to the function
void setgolf(golf & g, const char*name, int hc);
// function solicits name and handicap from user
// and sets the numbers of g to the values entered
// returns 1 if name is entered, 0 if name is empty string
int setgolf(golf & g);
// function resets handicap to new value
void handicap(golf & g, int hc);
//function displays contents of golf structure
void showgolf(const golf & g);
#endif
As far as I can tell the next file should ask for input and include main. I have gotten some of it done already.
#include <iostream>
#include "golf.h"
using namespace std;
int main()
{
char fullname[Len];
int handicap;
cout <<"Please enter your name and handicap: ";
while (cin >> fullname >> handicap)
{
One question that I have is what should come after while? The instructions in the book aren't as clear as I'd like.
The instructions are as follows:
Put together a multifile program based on the header: One file, named golf.cpp, should provide suitable function definitions to match the prototypes in the header file. A second file should contain main() and demonstrate all the features of the prototyped functions. For example, a loop should solicit input for an array of golf structures and terminate when the array is full or the user enters an empty string for the golfer's name. The main() function should use only the prototyped functions to access the golf structures.
Am I at least on the right track? Should golf.cpp even have main() in it? Or should that be pe9-1.cpp?
Any help will be very much appreciated.