$ gcc -o a.out *.c && ./a.out
one: 4
two: 4
one: 42
two: 4
Created
July 9, 2021 12:54
-
-
Save lightdiscord/2812773dcc334c5fcb541c69c9d62271 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#ifndef HEADER_H | |
# define HEADER_H | |
static int value = 4; | |
#endif |
This file contains hidden or 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 "header.h" | |
void checkValue(void); | |
int main(void) { | |
printf("one: %d\n", value); | |
checkValue(); | |
value = 42; | |
printf("one: %d\n", value); | |
checkValue(); | |
} |
This file contains hidden or 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 "header.h" | |
void checkValue(void) { | |
printf("two: %d\n", value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment