Created
March 14, 2019 22:03
-
-
Save kateolenya/bdf7a06fb14d5d2871cd3f1c53531ab5 to your computer and use it in GitHub Desktop.
Private function in C using static
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "private_funct.h" | |
#include <stdio.h> | |
#include <stdlib.h> | |
struct Contact | |
{ | |
int mobile_number; | |
int home_number; | |
}; | |
struct Contact * create_contact() | |
{ | |
struct Contact * some_contact; | |
some_contact = malloc(sizeof(struct Contact)); | |
some_contact->mobile_number = 12345678; | |
some_contact->home_number = 87654321; | |
return( some_contact ); | |
} | |
static void print_numbers( struct Contact * some_contact ) | |
{ | |
printf("Mobile number: %d, ", some_contact->mobile_number); | |
printf("home number = %d\n", some_contact->home_number); | |
} | |
void delete_contact( struct Contact * some_contact ) | |
{ | |
print_numbers(some_contact); | |
free(some_contact); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment