using struct

This is a discussion on using struct within the C++ Programming forums, part of the General Programming Boards category; If I have say 200 players and I want to use a struct for each one to hold various details ...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    101

    using struct

    If I have say 200 players and I want to use a struct for each one to hold various details about them including name etc can I give a struct an int as a name eg 'struct 1' and then use a loop to search through them for the name I am looking for eg 'for (x=1;x<+200;x++) if (x.name =="Smith").

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,303
    Use an array or some container like a std::vector.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 05-12-2011, 02:02 AM
  2. 2 problems: Struct array and pointer + struct
    By v1n1c1u5 in forum C Programming
    Replies: 0
    Last Post: 12-13-2009, 05:38 PM
  3. struct holding data inside a linked list struct
    By icestorm in forum C Programming
    Replies: 2
    Last Post: 10-06-2009, 01:49 PM
  4. Initialising struct array withing struct
    By Disco Elephant in forum C Programming
    Replies: 4
    Last Post: 08-16-2009, 11:17 AM
  5. returning a pointer of a struct of a struct array...
    By myrddinb in forum C Programming
    Replies: 1
    Last Post: 04-13-2004, 07:49 PM

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