Skip to main content
gamedev.net
🔒 Locked

get a memory error

Started by Da cobra Mar 18, 2003 at 10:35 AM 1 replies 200+ views
Original Post
Da cobra
Da cobra
can som1 pls try this code or tell me why I get a memory error when I run it?
        

#include <time.h>

#include <stdlib.h>

#include <iostream.h>

void main()
{
	// *** initialisation ***


	int dice[10] ;
	int counter = 0 ;
	int three = 0 ;
	int six = 0 ;

	// *** generate 10 random numbers ***

	for (counter = 1; counter <= 10; counter++)
	{
		srand ((unsigned)time(NULL)) ;
		dice[counter] = rand()%6 + 1;
		if (dice[counter] == 3)
		{
			three = three + 1 ;
		}
		else 
			if (dice[counter] == 6)
			{
				six = six + 1 ;
			}
		
	}
	
	// *** output ***

	system("cls") ;
	for (counter = 1; counter <= 10; counter++)
	{
		cout << "Dice " << counter << " = " << dice[counter] << endl ;
	}
	cout << endl ;
	cout << "thrown a 3 : " << three << endl ;
	cout << "thrown a 6 : " << six << endl ;
	
}

        
thanx in advance for any help [edited by - Da Cobra on March 18, 2003 11:37:41 AM]
da_cobra
da_cobra
damn, stupid mistake of me
thanx alot!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.