Skip to content

Instantly share code, notes, and snippets.

@McHippy3
Last active January 10, 2019 04:17
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 McHippy3/3ed5ed4b5f310aa3635eb4d6a97c949d to your computer and use it in GitHub Desktop.
Save McHippy3/3ed5ed4b5f310aa3635eb4d6a97c949d to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
typedef struct custInt
{
int i;
struct custInt *cI;
}
custInt;
custInt *a;
int main()
{
a = malloc(sizeof(custInt));
(*a).i = 8;
(*a).cI = NULL;
printf("%i\n", (*a).i);
custInt *b = a -> cI;
b = malloc(sizeof(custInt));
(*b).i = 7;
printf("%i\n" , (*b).i);
if(b == NULL)
{
printf("b is NULL");
}
if(a -> cI == NULL)
{
printf("custInt of a is NULL");
}
}
/* Results of Running
8
7
custInt of a is NULL
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment