The keyword you want is staticin a local (not global) context.
The meaning of the context is important:
#include <stdio.h>
static int foo;
int main(int argc, char **argv){
}
Here static, it means that it foohas a file area (i.e. not extern).
While
char *strtok(char *str, char *sep){
static char *last;
}
lastsaved between calls strtok.
All that has been said, they are rarely used, because they are rarely useful and completely unacceptable in a multi-threaded context (where they are waiting for the race condition).
source
share