home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!psgrain!hippo!ifkm
- From: ifkm@hippo.ru.ac.za (Andrew Murdoch)
- Subject: Address of static variables??
- Message-ID: <1992Sep11.115912.9604@hippo.ru.ac.za>
- Summary: Is address of statics constant?
- Keywords: static variables
- Organization: Rhodes University, Grahamstown, South Africa
- Date: Fri, 11 Sep 1992 11:59:12 GMT
- Lines: 26
-
-
- Consider this scenario:
-
- char *a_pointer;
-
- void some_function()
- {
- static char some_string[] = "Anything";
-
- // Do whatever here
- a_pointer = some_string;
- }
-
- void another_function()
- {
- ... some stuff
- do something with a_pointer
- }
-
- Is the static variable some_string always guaranteed to have
- the same address? That is, will a_pointer always be a valid
- pointer? Of course some_function would have to be called first.
- --
- |\/| v | ANDREW MURDOCH - Institute for Water Research
- /_\ | | \___@ | Rhodes University, P.O. Box 94, Grahamstown, 6140, R.S.A.
- / \ / \ | Internet: ifkm@hippo.ru.ac.za Phone: [xx27] [0]461 24014
-