From d8c2cd3061ab70329ba9979d21d3e7b6e7e1045a Mon Sep 17 00:00:00 2001 From: dsuclassprojects Date: Mon, 9 Dec 2019 20:15:43 -0600 Subject: [PATCH 1/2] made changes to buggy.c --- lab12-1.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 lab12-1.c diff --git a/lab12-1.c b/lab12-1.c new file mode 100644 index 0000000..0df5ece --- /dev/null +++ b/lab12-1.c @@ -0,0 +1,36 @@ +#include +#include + +/* 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 +{ + int age; + char name [10]; +}; + + +void main() +{ + struct dog thing1; + struct dog thing2; + + thing1.age = 5; + thing2.age = 13; + + puts("What is your dogs name? "); + gets(thing1.name); + + strcpy(thing2.name, "Buster"); + + printf("Name: %i\n",thing1.name); + printf("Age: %i\n",thing1.age); + printf("Thing2 Name: %s\n",thing2.name); + printf("Thing2 Age: %i\n",thing2.age); +} \ No newline at end of file From da6b664283aaaf8a264f70c63ae947b6aa03729c Mon Sep 17 00:00:00 2001 From: mattjager44 Date: Mon, 9 Dec 2019 20:52:09 -0600 Subject: [PATCH 2/2] made changes to buggy.c --- buggy.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/buggy.c b/buggy.c index aae42b1..0df5ece 100644 --- a/buggy.c +++ b/buggy.c @@ -7,31 +7,30 @@ 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 { int age; - char name = [10]; + char name [10]; }; void main() { - struct (dog) thing1: + struct dog thing1; struct dog thing2; - thing1.age = [5]; + thing1.age = 5; thing2.age = 13; - puts{"What is your dogs name? "}; - gets(thing1.names); + puts("What is your dogs name? "); + gets(thing1.name); strcpy(thing2.name, "Buster"); - printf("Name: %i\n",thing1.name ); - printf("Age: %i\n",thing1.age): - printf("Thing2 Name: %s\n,thing2.name); - printf("Thing2 Age %i\n',thing2.age); + printf("Name: %i\n",thing1.name); + printf("Age: %i\n",thing1.age); + printf("Thing2 Name: %s\n",thing2.name); + printf("Thing2 Age: %i\n",thing2.age); } \ No newline at end of file