Thread: arrays

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    196

    arrays

    ok in the tutorial im reading it only shows uses for arrays using strings
    http://www.zeuscmd.com/tutorials/cpl.../07-Arrays.php

    so how could i use arrays for things like invenotorys and stuff?

    just a simple code is all i ask even if only 1 or 2 lines

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Here is a simple example using enums.

    Code:
    const int MAX_INV = 5;
    
    //An enum for the different types
    //of objects we will have
    enum eInvObject{
    	eInvObjectSword,
    	eInvObjectArmor,
    	eInvObjectHotChick,
    	eInvObjectAbsoutlyNoChicks,
    	
    	eInvObjectNone
    };
    
    int main()
    {
    	//Set up the arrays
    	eInvObject eInventoryBmans[MAX_INV];
    	eInvObject eInventoryMajorSmalls[MAX_INV];
    	
    	for(int i = 0; i < MAX_INV; i++){
    		//You know it!
    		eInventoryBmans[i] = eInvObjectHotChick;
    		eInventoryMajorSmalls[i] = eInvObjectAbsoutlyNoChicks;
    	}
    	
    	return 0;
    }
    Woop?

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    thanks that makes it somewhat clearer

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Heh, way to refer to women as objects, prog.
    Sent from my iPadŽ

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    hey hey he said hot chicks dont forget that

  6. #6
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    You know how I do Sly
    Woop?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  2. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  3. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  4. Building B-Tree from Arrays
    By 0rion in forum C Programming
    Replies: 1
    Last Post: 04-09-2005, 02:34 AM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM