Getting srand and rand errors? Help!!

From previous questions, I rewrote my whole program. I had to write a profram to all the user to roll two dice. Well I am getting errors that the srand and rand are not being identify. Can someone please help? I will list my code and the errors. Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "stdio.h"

int keepPlaying(int);

int main()
{
	int bankroll = 100; /* sum of bankroll */
	int die1; /* firs die */
	int die2; /* second die */
	int sum; /* sum of dice */

	srand( time( NULL ) ); /* randomize random number grenerator using current time */

	while ( keepPlaying(bankroll) ) {
		die1 = 1 + ( rand() % 6 );
		die2 = 1 + ( rand() % 6 ); 
		sum = die1 + die2;

		if ( sum == 7 ) {
			bankroll += 50; 
		} else {
			bankroll -= 10;
		}
	}

	if ( bankroll >= 100 ) {
		printf( "Thanks for playing. You have won $%d\n", bankroll - 100);
	} else {
		printf( "Thanks for playing. You have lost $%d\n", bankroll - 100);
	}

	system("pause");
	return 0;
}

int keepPlaying(int bankroll) {
	int rollAgain = 0;
	int inputValue = -1;

	if (bankroll >= 0) {
		printf( "Your bankroll is $%d, enter '0' to quit or '1' to keep playing:", bankroll);

		scanf( "%d", &inputValue );
		if ( inputValue != -1 && inputValue != 0 ) {
			rollAgain = 1;
		}
	}
	return rollAgain;
}


my errors are:

1>------ Rebuild All started: Project: Program2, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'Program2', configuration 'Debug|Win32'
1>Compiling...
1>Program2.cpp
1>c:\users\jennifer\documents\visual studio 2008\projects\program2\program2\program2.cpp(14) : error C3861: 'srand': identifier not found
1>c:\users\jennifer\documents\visual studio 2008\projects\program2\program2\program2.cpp(14) : error C3861: 'time': identifier not found
1>c:\users\jennifer\documents\visual studio 2008\projects\program2\program2\program2.cpp(17) : error C3861: 'rand': identifier not found
1>c:\users\jennifer\documents\visual studio 2008\projects\program2\program2\program2.cpp(18) : error C3861: 'rand': identifier not found
1>c:\users\jennifer\documents\visual studio 2008\projects\program2\program2\program2.cpp(34) : error C3861: 'system': identifier not found
1>Build log was saved at "file://c:\Users\Jennifer\Documents\Visual Studio 2008\Projects\Program2\Program2\Debug\BuildLog.htm"
1>Program2 - 5 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


you should include these libraries
1
2
#include <cstdlib>
#include <ctime> 


to use srand and time and system

I never use visual studio before but this is the standard so the library should be there

sorry I am new at this. Where do I put those libraries? in my .cpp or.h?
nevermind!! I figured it out and it's working!! Thanks so much!!
Topic archived. No new replies allowed.