Thread: Weird command prompt error, program not working..

  1. #16
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    Actually I think you are maybe wrong... because 13x4=52...
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  2. #17
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Code:
    class Deck
    {
    public:
        Deck()
        {
            int x;
            int y;
            int z = 0;
            for (y = 0; y < 4;  y++)
            {
                for (x = 0; x < 13; x++)
                {
                    Cards[z].suit = y;
                    Cards[z].value = x;
                    z++;
                }
            }
        }
    
    
    //private:
    	Card Cards[52];
    };
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #18
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    But 4 * 14 is 56!

    And your second loop will run 0..13, which is 14 iterations, not 13, just like your first loop runs 0..3, which is 4 iterations.

    [Just because I made one mistake doesn't mean that everything else I said is wrong!]

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #19
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    awesome its all fixed up now, thanks for your help guys

    Code:
    struct Card
    {
    	int suit;
    	int value;
    };
    
    class Deck
    {
    public:
    	Deck()
    	{
    		int x;
    		int y;
    		int z = 0;
    			for (y = 0; y < 4;  y++)
    			{
    				for (x = 0; x < 13; x++)
    				{
    					Cards[z].suit = y;
    					Cards[z].value = x;
    					z++;
    				}
    			}
    	}
    
    
    //private:
    	Card Cards[52];
    };
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. weird things with my linked list of queue
    By -EquinoX- in forum C Programming
    Replies: 3
    Last Post: 11-22-2008, 11:23 PM
  2. some really weird problems with string !
    By mellisa in forum C++ Programming
    Replies: 2
    Last Post: 01-20-2003, 04:56 AM
  3. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM
  4. Direct Draw weird stuff
    By Magos in forum C++ Programming
    Replies: 6
    Last Post: 04-24-2002, 04:39 AM
  5. getting current working filename
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 04-17-2002, 03:42 PM