Skip to content

Instantly share code, notes, and snippets.

@kateolenya
Last active March 14, 2019 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kateolenya/316e04fd18aeab584514c00bd17ef6a3 to your computer and use it in GitHub Desktop.
Save kateolenya/316e04fd18aeab584514c00bd17ef6a3 to your computer and use it in GitHub Desktop.
Private variables in struct in C
#include "private_var.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 );
}
void delete_contact( struct Contact * some_contact )
{
free(some_contact);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment