#include<stdio.h>

/**
 * Terry Harvey CIS 105 Section 010 TA Tina Weymouth
 *  Demonstration program for structs
 **/

typedef struct{
    int num_legs;
    //int aspamn = 8; illegal to initialize
    char name[20];
} Pet;  //this makes a new type called Pet

void printPet( Pet p );
void changePet( Pet p );

int main(){

    Pet p1;
    Pet p2 = {4, "Mildred"};
    p1.num_legs = 4;
    
    printf("p1 has %d legs.\n", p1.num_legs);
    printPet( p2 );
    changePet( p2) ;
    printPet( p2 ); //this shows structs are pass-by-value
    return 0;

}

void printPet( Pet p ){
    printf("p has %d legs and is named %s.\n", p.num_legs, p.name);
    return;
}

void changePet( Pet p ){
    p.num_legs = 5;
    p.name[0] = 'W';
    printf("inside changePet: ");
    printPet(p);
    return;
}


