Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!ptsfa!ihnp4!homxb!genesis!hotlg!anumb!eao From: eao@anumb.UUCP (e.a.olson) Newsgroups: comp.lang.c Subject: Re: C pointer to a function Message-ID: <126@anumb.UUCP> Date: Mon, 28-Sep-87 22:16:46 EDT Article-I.D.: anumb.126 Posted: Mon Sep 28 22:16:46 1987 Date-Received: Thu, 1-Oct-87 02:21:53 EDT References: <501@acf3.NYU.EDU> Distribution: na Organization: AT&T Bell Labs, Andover MA Lines: 40 > > Consider the function foo, defined as: > > static char *foo(name) > char *name; > { > static char path[20]; > char *strcat(); > > ... > > return(strcat(path, name); > } > > and invoked in the following manner: > > callfoo() > char *name; > { > char *path, *foo(); > > ... > > path = foo(name); > > ... > > } > > The question here concerns the scope of the pointer to > the function foo. > Specifically, why might the pointer be defined as static? > (An example of this can be found on p.23 of Marc Rochkind's > book, "Advanced Unix Programming", 4th printing.) > Well, one good reason might be that the function is considered part of the data structure and that static is used to hide it. :-) 7