home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / atari / st / tech / 4159 < prev    next >
Encoding:
Text File  |  1992-07-28  |  1.6 KB  |  42 lines

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!swrinde!mips!darwin.sura.net!ua1ix!ua1vm.ua.edu!MDORMAN1
  2. From: MDORMAN1@ua1vm.ua.edu (Mike Dorman)
  3. Newsgroups: comp.sys.atari.st.tech
  4. Subject: A "C" question...
  5. Message-ID: <16832DDF3.MDORMAN1@ua1vm.ua.edu>
  6. Date: 28 Jul 92 20:46:58 GMT
  7. Sender: news@ua1ix.ua.edu
  8. Organization: The University of Alabama, Tuscaloosa
  9. Lines: 30
  10. Nntp-Posting-Host: ua1vm.ua.edu
  11.  
  12. I've got a question about how to do something in "C".
  13.  
  14. I'm in the process of writing a C library to make it easier to manage windows
  15. (some of the nasty stuff like outputting text through a printf()-like
  16. interface, etc).
  17.  
  18. I have a structure that describes large parts of the window (things like its
  19. current size, the window handle, etc.).  One of the things I've been thinking
  20. about doing is storing the window name and info fields as part of the structre.
  21.  
  22. Now, obviously, I don't want to have them allocated if they're not going to
  23. be used.  So I was thinking of creating functions wx_name() and wx_info(),
  24. where the function definition would be something like:
  25.  
  26. wx_name(ws,str)
  27. Window ws;
  28. char *str;
  29.  
  30. I would then like to malloc() memory to hold the string that we've been given
  31. so that we won't use any more memory than necessary (I have an ulterior motive,
  32. I want to create a printf() interface to this stuff, too--I have a couple of
  33. programs that could use it).
  34.  
  35. So, what's the best way to declare the variable within the structure?  Is
  36. merely making it a char * sufficient, or do I need to make it static char *?
  37.  
  38. I never have been able to figure out just what the difference is in practical
  39. terms.  If someone could explain, I'd be deeply indebted.
  40.  
  41. Mike.
  42.