-
-
Save McHippy3/3ed5ed4b5f310aa3635eb4d6a97c949d to your computer and use it in GitHub Desktop.
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 <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