home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13518 < prev    next >
Encoding:
Text File  |  1992-09-11  |  1.0 KB  |  38 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!psgrain!hippo!ifkm
  3. From: ifkm@hippo.ru.ac.za (Andrew Murdoch)
  4. Subject: Address of static variables??
  5. Message-ID: <1992Sep11.115912.9604@hippo.ru.ac.za>
  6. Summary: Is address of statics constant?
  7. Keywords: static variables
  8. Organization: Rhodes University, Grahamstown, South Africa
  9. Date: Fri, 11 Sep 1992 11:59:12 GMT
  10. Lines: 26
  11.  
  12.  
  13. Consider this scenario:
  14.  
  15. char *a_pointer;
  16.  
  17. void some_function()
  18. {
  19.    static char some_string[] = "Anything";
  20.  
  21.    // Do whatever here
  22.    a_pointer = some_string;
  23. }
  24.  
  25. void another_function()
  26. {
  27.    ... some stuff
  28.    do something with a_pointer
  29. }
  30.  
  31. Is the static variable some_string always guaranteed to have
  32. the same address?  That is, will a_pointer always be a valid
  33. pointer?  Of course some_function would have to be called first.
  34. -- 
  35.      |\/|     v |     ANDREW MURDOCH   -   Institute for Water Research
  36.  /_\ |  | \___@ |  Rhodes University, P.O. Box 94, Grahamstown, 6140, R.S.A.
  37. /   \     /   \ | Internet: ifkm@hippo.ru.ac.za     Phone: [xx27] [0]461 24014
  38.