home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!netnews!bandy
- From: bandy@netnews.jhuapl.edu (Mike Bandy)
- Subject: Re: Why would someone put 'char x[]' inside of a struct decl?
- Message-ID: <C0CB20.201@netnews.jhuapl.edu>
- Organization: JHU/Applied Physics Laboratory
- References: <wyrr3hn@lynx.unm.edu>
- Date: Mon, 4 Jan 1993 17:25:12 GMT
- Lines: 38
-
- peter@deepthought.unm.edu (Peter Blemel) writes:
-
- >I'm trying (really I am) to write a Microsoft Windows app, and I've come across
- >a structure (Prog ref, vol 4 pg90) that looks something like...
-
- >struct DialogBoxHeader {
- > char szMenuName[];
- > char szFaceName[];
- >};
-
- >First, this reference sucks. It doesn't explain how to use this and a companion
- >structure (on the following page) together. Second, I can't figure out how to
- >initialize this structure(?). szMenuName isn't allocated any storage, and I can't
- >allocate any for it because it's not a lvalue.
-
- Look at the struct as:
-
- struct DialogBoxHeader {
- char *szMenuName;
- char *szFaceName;
- };
-
- Then the fields are pointers to character strings that you supply. So you
- can do:
-
- #define MyMenuName "Projects"
- ...
- struct DialogBoxHeader DBH;
- ...
- DBH.sz_MenuName = MyMenuName;
-
- (Note, I'm not a Windows programmer, but AmigaDOS does similar things.)
-
- --
-
- Mike Bandy
- bandy@aplcomm.jhuapl.edu
- Johns Hopkins University / Applied Physics Lab
-