home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19188 < prev    next >
Encoding:
Text File  |  1993-01-04  |  1.3 KB  |  49 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!netnews!bandy
  3. From: bandy@netnews.jhuapl.edu (Mike Bandy)
  4. Subject: Re: Why would someone put 'char x[]' inside of a struct decl?
  5. Message-ID: <C0CB20.201@netnews.jhuapl.edu>
  6. Organization: JHU/Applied Physics Laboratory
  7. References: <wyrr3hn@lynx.unm.edu>
  8. Date: Mon, 4 Jan 1993 17:25:12 GMT
  9. Lines: 38
  10.  
  11. peter@deepthought.unm.edu (Peter Blemel) writes:
  12.  
  13. >I'm trying (really I am) to write a Microsoft Windows app, and I've come across
  14. >a structure (Prog ref, vol 4 pg90) that looks something like...
  15.  
  16. >struct DialogBoxHeader {
  17. >    char szMenuName[];
  18. >    char szFaceName[];
  19. >};
  20.  
  21. >First, this reference sucks. It doesn't explain how to use this and a companion
  22. >structure (on the following page) together. Second, I can't figure out how to
  23. >initialize this structure(?). szMenuName isn't allocated any storage, and I can't
  24. >allocate any for it because it's not a lvalue. 
  25.  
  26. Look at the struct as:
  27.  
  28. struct DialogBoxHeader {
  29.     char *szMenuName;
  30.     char *szFaceName;
  31. };
  32.  
  33. Then the fields are pointers to character strings that you supply.  So you
  34. can do:
  35.  
  36. #define MyMenuName "Projects"
  37. ...
  38. struct DialogBoxHeader DBH;
  39. ...
  40. DBH.sz_MenuName = MyMenuName;
  41.  
  42. (Note, I'm not a Windows programmer, but AmigaDOS does similar things.)
  43.  
  44. -- 
  45.  
  46.     Mike Bandy
  47.     bandy@aplcomm.jhuapl.edu
  48.     Johns Hopkins University / Applied Physics Lab
  49.