vendredi 17 mars 2017

Creating a Random Number Generator srand and rand undefined

I'm using virtual studio and it keeps tagging srand and rand as being undefined. Project is setup as a visual c++ win32 project. #include cstdlib and #include ctime are implemented as well.

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>

using namespace std;



void randomNumberGen();

void main() {
randomNumberGen();
return;
}

 void randomNumberGen()
 {
 ofstream randomNumberDocument;
 unsigned seed = time(0);
 srand(seed);

 for(int i=1; i<=10; i++)
 cout << rand() << endl;
 }

I know this is not a fully functioning program yet and fstream is not implemeted yet. I wanted to fix problems before moving on




Aucun commentaire:

Enregistrer un commentaire