-
August 9th, 2012, 03:26 PM
#1
[RESOLVED] Creating a random number generator program help
I'm trying to create a program that creates random numbers. I looked through some examples and this is what I came up with. The time identifier seems to be undefined yet I see no reason it is undefined. please help!
Code:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
//Re-seed the random-number generator
time_t now;
time(&now);
srand(now);
rand();
//Print out a list of random numbers
for (int i=0;i<5;i++)
{
cout << rand() % 100 << endl;
}
system("pause");
return 0;
}
here's my error code..
1>------ Build started: Project: bake, Configuration: Debug Win32 ------
1> bake.cpp
1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(8): error C3861: 'time': identifier not found
1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(9): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
-
August 9th, 2012, 03:35 PM
#2
Re: Creating a random number generator program help
Maybe you should include time.h?
-
August 9th, 2012, 03:38 PM
#3
Re: Creating a random number generator program help
oh DUH haha, thank you so much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|