Structure

Discussion in 'C Programming' started by Jake Thompson, Jan 9, 2006.

  1. Do you need to allocate a structure before you use it if it only holds
    one instance and is not in array format?
    Jake Thompson, Jan 9, 2006
    #1
    1. Advertising

  2. Jake Thompson

    pemo Guest

    "Jake Thompson" <> wrote in message
    news:...
    > Do you need to allocate a structure before you use it if it only holds
    > one instance and is not in array format?


    How could you use it if it isn't declared/defined?
    pemo, Jan 9, 2006
    #2
    1. Advertising

  3. Jake Thompson

    Benry Guest

    Only if it contains a pointer, or anything that takes up memory. If a
    struct just has an int or something in it, you don't have to allocate
    any memory.
    Benry, Jan 9, 2006
    #3
  4. Jake Thompson

    Default User Guest

    Jake Thompson wrote:

    > Do you need to allocate a structure before you use it if it only holds
    > one instance and is not in array format?


    What do you mean by "allocate". Please give an example.



    Brian

    --
    Please quote enough of the previous message for context. To do so from
    Google, click "show options" and use the Reply shown in the expanded
    header.
    Default User, Jan 9, 2006
    #4
  5. "Benry" <> writes:
    > Only if it contains a pointer, or anything that takes up memory. If a
    > struct just has an int or something in it, you don't have to allocate
    > any memory.


    Context is important; please read <http://cfaj.freeshell.org/google/>.

    Of course you have to allocate memory for it. You can do so either by
    calling an allocation function such as malloc(), or by declaring an
    object (which implicitly allocates memory).

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Jan 9, 2006
    #5
  6. Jake Thompson

    Benry Guest

    Keith Thompson wrote:
    > "Benry" <> writes:
    > > Only if it contains a pointer, or anything that takes up memory. If a
    > > struct just has an int or something in it, you don't have to allocate
    > > any memory.

    >
    > Context is important; please read <http://cfaj.freeshell.org/google/>.



    Thank you, and I'm sorry!

    -Ben
    Benry, Jan 12, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Excluded_Middle

    Pointers to structure and array of structure.

    Excluded_Middle, Oct 24, 2004, in forum: C Programming
    Replies:
    4
    Views:
    721
    Martin Ambuhl
    Oct 26, 2004
  2. Leo Nunez
    Replies:
    3
    Views:
    1,177
    Neil Kurzman
    Feb 9, 2005
  3. Replies:
    2
    Views:
    579
  4. Replies:
    9
    Views:
    25,205
    Lal Bahadur Singh
    Nov 11, 2011
  5. meisterbartsch
    Replies:
    2
    Views:
    750
    meisterbartsch
    Jun 12, 2007
Loading...

Share This Page