Okay, so pretty much I have to use structs to print out information about 4 dogs. However, I can only get the first dog, Smokey's information to print. Any advice on how to get the other four to print?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define pause system("pause")
#define SIZE 100

//Write your structs here
  typedef struct{
      char name[SIZE];
      int age;
      int weight;
      char breed[SIZE];
  } DOG;

//Prototype your functions here
  void displayDog(DOG);
  void loadDog(DOG *s);
  void loadDog2(DOG *s);
  void loadDog3(DOG *s);
  void loadDog4(DOG *s);

main(){
    DOG Smokey, Oscar, Leo, Jose;
    loadDog(&Smokey);
    loadDog(&Oscar);
    loadDog(&Leo);
    loadDog(&Jose);
    displayDog(Smokey);
    displayDog(Oscar);
    displayDog(Leo);
    displayDog(Jose);

    pause;

}//end main


void displayDog(DOG s){
    printf("Student name.....: %s. \n", s.name);
    printf("Age.....: %i. \n", s.age);
    printf("Weight.....: %i. \n", s.weight);
    printf("Breed.....: %s. \n\n", s.breed);
}//end displayDog


void loadDog(DOG *s){
    strcpy(s->name,"Smokey");
    s->age = 5;
    s->weight = 27;
    strcpy(s->breed,"Boston Terrier");
}
//end loadDog

void loadDog2(DOG *s){
    strcpy(s->name,"Oscar");
    s->age = 2;
    s->weight = 70;
    strcpy(s->breed,"German Shepard");
}
//end loadDog

void loadDog3(DOG *s){
    strcpy(s->name,"Leo");
    s->age = 6;
    s->weight = 50;
    strcpy(s->breed,"Siberian Husky");
}
//end loadDog

void loadDog4(DOG *s){
    strcpy(s->name,"Jose");
    s->age = 1;
    s->weight = 60;
    strcpy(s->breed,"Dalmation");
}
//end loadDog

You are using the same function, loadDog, to put data into all the four dog objects, so you are loading the Smokey data into all four. Perahps you meant to use each loading function once (loadDog, loadDog2, loadDog3, loadDog4).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.