Basic Structure

You will be writing a program that parses its command-line arguments, puts the information into a structure that you define, then test the effects of various parameter-passing models on data. You will also be doing simple pointer manipulation.

At the bottom of this page is a rough template for your program: copy it as your starting point. A quick outline of what your program will do:

  1. Define the "Date" struct, outside of main()
  2. Declare a local variable "myDate", of type "Date"
  3. Call ModifyDate, then print out the effect on myDate
  4. Call ModifyDateForReal, then print out the effect on myDate

We will be fleshing the main function out in subsequent steps.

Use the following as the starting skeleton for your program:
(Do not be concerned right now about how complex the template seems-- we will fill out each part together one by one in the following steps.)


#include <iostream>

// ADD #include's HERE FOR ANY OTHER LIBRARIES YOU USE

using namespace std;

// ADD ANY GLOBAL CONSTANTS HERE

// STEP 1: ADD YOUR "Date" STRUCTURE DEFINITION HERE

int main(int argc, char *argv[]) {

    // STEP 2: DECLARE A LOCAL VARIABLE "myDate" HERE, OF TYPE "Date"
    //   INITIALIZE THE MEMBERS OF "myDate" TO REPRESENT 1/1/2001,
    //   WITH TYPE == 'H' FOR "holiday"

    // STEP 3: WRITE THE FUNCTION ModifyDate() DOWN BELOW, AFTER main().
    // ADD CALL TO ModifyDate() HERE, PASSING IN myDate AS ARGUMENT

    // AFTER IT RETURNS, PRINT OUT THE CONTENTS OF myDate

    // STEP 4: WRITE THE FUNCTION ModifyDateForReal() DOWN BELOW, AFTER main().
    // ADD CALL TO ModifyDateForReal() HERE, PASSING IN myDate AS ARGUMENT

    // AFTER IT RETURNS, PRINT OUT THE CONTENTS OF myDate
    // (Step 4 can be done by just cutting-and-pasting Step 3 above, then
    //  editing it slightly)



    return 0;
}

//
// NOW, ADD YOUR OTHER FUNCTIONS HERE
//   (Do not put it ABOVE main()! )
//