Thread: Empty Array?

  1. #1
    Registered User Terran's Avatar
    Join Date
    May 2008
    Location
    Nashua, NH
    Posts
    100

    Empty Array?

    Whats the best way to test if an array is completely empty then have something happen? e.g. if you have an array of enemies and you want to check if they're all dead then move on to the next level?
    Sorry, but i'm a Code::Blocks man now.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you were only using a vector, you can test its size. Otherwise you'll have to (1) loop and count or (2) keep track as you add/delete.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Arrays don't have a concept of empty; vectors do but not arrays.
    Arrays always hold something at each valid index even if it is say a zero value or a NULL pointer or a default constructed object.

    You'd need to show code.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 1-D array
    By jack999 in forum C++ Programming
    Replies: 24
    Last Post: 05-12-2006, 07:01 PM
  2. 2d array question
    By gmanUK in forum C Programming
    Replies: 2
    Last Post: 04-21-2006, 12:20 PM
  3. Template Array Class
    By hpy_gilmore8 in forum C++ Programming
    Replies: 15
    Last Post: 04-11-2004, 11:15 PM
  4. two dimensional dynamic array?
    By ichijoji in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2003, 04:27 PM
  5. making an empty 2-D array
    By starX in forum C Programming
    Replies: 4
    Last Post: 02-08-2002, 01:09 AM