Thread: My code wont generate randon numbers

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    4

    Question My code wont generate random numbers

    please help me my program is done all i need is to make random numbers, but for some reason i keep on getting the same number over and over heres the code for a part of this program

    Code:
    #include <iostream>
    #include <iomanip>
    #include <ctime>
    using namespace std;
    
    
    int main(void)
    {
    	double dPot=100.0;   //Starting Pot Size
    	double dBet=0.0;     //Bet that user inputs  
    	int iHand=0;        //Addidtion of users cards
    	char cAns;         //answer either y/n
    	srand((unsigned)time(NULL));
    	unsigned int uiHand=0,uiCurrentCard=0,uiDealer=16;
    	  uiCurrentCard= rand()%10;
    	  
    	  //users card
    	cout <<"\t\t\t\tWelcome to 21!\n\n\n";//title 
    		
    	//getting users Bet
    	
    	do{
    		cout<<"You have " <<dPot<< " dollars to bet with\n\n";
    		cout<<"How much would you like to bet? ";
    		cin>>dBet;
    
    		//make sure its a vaild bet and pass all tests
    		 while((dBet<=0)||(dBet>dPot)||(cin.fail()))
    		 {
    			cin.clear();
    			cin.ignore(cin.rdbuf()->in_avail(),'\n');
    			cout<<"Sorry that was an invaild bet.\n";
    			cout<<"How much would you like to bet? ";
    			cin>>dBet;
    		 }
    			//give Player first Card Ask him if he wants another
    so when i cout uiCurrentCard i always get the same number thro the program why is that?
    Last edited by n00b_101; 10-20-2005 at 01:07 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  2. Can someone help me understand this example program
    By Guti14 in forum C Programming
    Replies: 6
    Last Post: 09-06-2004, 12:19 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  4. << !! Posting Code? Read this First !! >>
    By biosx in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2002, 12:51 PM
  5. who can sent me code about 8 numbers
    By xacoolboy in forum C Programming
    Replies: 7
    Last Post: 03-08-2002, 07:33 PM