+ 1
Why in C++ randomize() go out of scope when I decleared it in main() and included the header file stdlib. h????
randomize function out of scope
3 ответов
+ 7
randomize() random() is a pre standardized C++ way of doing things and is usually only available in Turbo C++ and Dev C++ compilers which are very old. This form of getting random numbers won't work in the playground as it uses standardized C++ that conforms to the ANSI C++ Standard. You need to use rand() and srand() instead.
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main()
{
srand(time(0));
int x=5;
x = rand() % x + x;
cout << x;
return 0;
}
+ 3
Provide the code so we can see what the problem might be.