#include <stdio.h>
#include <string.h>
void stuff();
main()
{
int val = 10;
printf("from main: %d\n", val);
stuff();
printf("from main: %d\n", val);
stuff();
}
void stuff()
{
int val = 5;
printf("from stuff: %d\n", val);
}
It doesn’t matter to define int val many times, since it does matter in which area it is defined, this will result in 10 5 10 5 output, no errors without bad behavior
source
share