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