Why some people do:
char baa(int x) {
static char foo[] = \" .. \";
return foo[x ..];
}
instead of:
char baa(int x) {
Yes, the performance is different: unlike variables in the automatic storage that are initialized every time, static variables are initialized only once, the first time you go through the function. If foo
is not written to, there is no other differences. If it is written to, the changes to static variables survive between calls, while changes to automatic variables get lost the next time through the function.