In reply to mlsxdx:
A static variable is global. If you do not want that behavior, then do not use a static variable. You need to change your code to
int get_miles(const int *miles) {
*miles = *miles + 1;
return *miles;
}
void runner1() {
int i, miles;
for(i=0;i<5;i++) {
printf("runner1 runs %0d miles\n", get_miles(&miles));
}
}
void runner2() {
int j, miles;
for(j=0;j<5;j++) {
printf("runner2 runs %0d miles\n", get_miles(&miles));
}
}