Scope of 'static' variables

Doug Gwyn gwyn at smoke.brl.mil
Sat Dec 8 06:32:11 AEST 1990


In article <1990Dec7.051955.2883 at mintaka.lcs.mit.edu> dstailey at gnu.ai.mit.edu (Doug Stailey) writes:
>But what if you want to call a function returning a static from another
>source module?  Say for instance, in main.c you have a function declared:
>static char *get_cmd(FILE *fp)

"static" applies to the function; it has NOTHING to do with the value
returned.  Thus "function returning a static" is incorrect terminology.
"The function is statically defined" would be acceptable.

	extern char *example(void);

	char *example(void) {
		static char buffer[100];
		/*...*/
		return buffer;
	}



More information about the Comp.lang.c mailing list