According to this string literals are always static. This makes me wonder whether the following functions do exactly the same:
static const char *foo1(void) {return "bar";}
static const char *foo2(void) {const char *bar = "bar";return bar;}
static const char *foo3(void) {static const char *bar = "bar";return bar;}
Is there any significant difference between foo1
, foo2
and foo3
or not? In other words: Is using the static
keyword superfluous when declaring string literals inside functions?