structure array

This is a discussion on structure array within the C Programming forums, part of the General Programming Boards category; How can I assign the same structure multiple times to an array. For example "my_struct array[0]", "my_struct array[1]" and so ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    6

    structure array

    How can I assign the same structure multiple times to an array.
    For example "my_struct array[0]", "my_struct array[1]" and so on, so that array[0] is the same as array[1]. The reason I want to do this is because later on I will use these arrays and give them different values so that the same structure elements in array[0] will have different values from the elements in array[1].

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Code:
    for (i = 1; i < array_count; i++)
    {
         array[i] = array[0];
    }

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    6
    I wish it was that simple. The whole problem is how to put a structure in array so that array[0] will point to my_struct.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Structure or Array?
    By epi_jimenez in forum C Programming
    Replies: 7
    Last Post: 04-01-2009, 02:45 PM
  2. linear search for structure (record) array
    By jereland in forum C Programming
    Replies: 3
    Last Post: 04-21-2004, 07:31 AM
  3. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 12:01 AM
  4. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 11:09 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21