In the C variables and types post I introduced how to work with variables.
In this post I want to mention the difference between global and local variables.
A local variable is defined inside a function, and it’s only available inside that function.
Like this:
#include <stdio.h>
int main(void) {
char j = 0;
j += 10;
printf("%u", j); //10
}
j is not available anywhere outside the main function.
#c #c# #c++ #programming-c