Skip to content

Conversation

@mlgriffith
Copy link

char name = [10] -> char name[10]
struct (dog) thing1 -> struct dog thing1
colon -> semicolon
thing1.age = [5] -> thing1.age = 5
puts{"What is your dog's name? "} -> puts("What is your dog's name? ")
gets(thing1.names) -> gets(thing1.name)
printf("Name: %i\n",thing1.name ); -> string, printf("Name: %s\n",thing1.name );
colon -> semicolon
printf("Thing2 Name: %s\n,thing2.name); -> printf("Thing2 Name: %s\n",thing2.name);
printf("Thing2 Age %i\n',thing2.age); -> printf("Thing2 Age: %i\n",thing2.age);

#include <stdio.h>
#include <string.h>

/* Assignment:

  1. fix bugs in the code
  2. add comments
  3. create a new branch on git
  4. git push changed buggy.c
  5. create pull request with your name and changes you made

*/

struct dog // initiate struct
{
int age; // declare variable for age
char name[10]; // declare variable and count for name
};

void main() // function main begins program execution
{
struct dog thing1; // declare struct thing1
struct dog thing2; // declare struct thing2

thing1.age = 5; // declare age thing1
thing2.age = 13; // declare age thing2

puts("What is your dogs name? "); // prompt user for input
gets(thing1.name); // display input 

strcpy(thing2.name, "Buster"); // initiate strcpy

string, printf("Name: %s\n",thing1.name ); // display name of thing1
printf("Age: %i\n",thing1.age); // display age of thing1
printf("Thing2 Name: %s\n",thing2.name); // display name of thing2
printf("Thing2 Age %i\n",thing2.age); // display age of thing2

} // end function main

@baylieembry baylieembry mentioned this pull request Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant