Skip to content

Commit f26d3e8

Browse files
committed
Task 5 of 0x0E structures and typedef
1 parent b970698 commit f26d3e8

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

0x0E-structures_typedef/.swp

12 KB
Binary file not shown.

0x0E-structures_typedef/5-free_dog.c

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdlib.h>
2+
#include "dog.h"
3+
4+
/**
5+
* free_dogs - function that frees dogs
6+
* @d: structures
7+
*
8+
* Return: 0
9+
*/
10+
11+
void free_dog(dog_t *d)
12+
{
13+
if (d != NULL)
14+
{
15+
free(d->owner);
16+
free(d->name);
17+
free(d);
18+
}
19+
}

0x0E-structures_typedef/5-main.c

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <stdio.h>
2+
#include "dog.h"
3+
4+
/**
5+
* main - check the code
6+
*
7+
* Return: Always 0.
8+
*/
9+
int main(void)
10+
{
11+
dog_t *my_dog;
12+
13+
my_dog = new_dog("Poppy", 3.5, "Bob");
14+
printf("My name is %s, and I am %.1f :) - Woof!\n", my_dog->name, my_dog->age);
15+
free_dog(my_dog);
16+
return (0);
17+
}

0x0E-structures_typedef/f

16.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)