Originally Posted by
stahta01
He his using the same main.c file as the prior poster.
Tim S.
I do not understand what you mean
test.h
Code:
#ifndef TEST_H_INCLUDED#define TEST_H_INCLUDED
void Func();
#endif
test.c
Code:
#include <stdio.h>#include "test.h"
void Func() {
static int x = 0;
x++;
printf("%d\n", x);
}
main.c
Code:
#include<stdio.h>#include "test.h"
int main() {
Func(); // prints 1
Func(); // prints 2
Func(); // prints 3
Func(); // prints 4
Func(); // prints 5
return 0;
}
The output is as follows
1
2
3
4
5