Skip to content

Commit

Permalink
free dog
Browse files Browse the repository at this point in the history
  • Loading branch information
Sakhinamammadzade committed Nov 21, 2023
1 parent 3363489 commit c2b12cb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions structures_typedef/5-free_dog.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdlib.h>
#include "dog.h"

/**
* free_dog - frees dogs
* @d: pointer to dog to free
*
* Return: void
*/
void free_dog(dog_t *d)
{
if (d)
{
free(d->name);
free(d->owner);
free(d);
}
}
17 changes: 17 additions & 0 deletions structures_typedef/5-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>
#include "dog.h"

/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
dog_t *my_dog;

my_dog = new_dog("Poppy", 3.5, "Bob");
printf("My name is %s, and I am %.1f :) - Woof!\n", my_dog->name, my_dog->age);
free_dog(my_dog);
return (0);
}

0 comments on commit c2b12cb

Please sign in to comment.