Skip to content

Instantly share code, notes, and snippets.

@Jay-flow
Created June 25, 2020 11:15
Show Gist options
  • Save Jay-flow/fc1a36fac41cfc245ae5519300f091c4 to your computer and use it in GitHub Desktop.
Save Jay-flow/fc1a36fac41cfc245ae5519300f091c4 to your computer and use it in GitHub Desktop.
How the computer handles variables
#include <stdio.h>
void addValue() {
// It doesn't reset every time I call.
static int a = 10;
a = a + 10;
printf("%d\n", a);
}
int main(void) {
addValue()
addValue()
addValue()
addValue()
addValue()
// a = 60
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment