vendredi 17 avril 2020

does visual studio code have an issue with the use of random supported in C++?

Im having an issue regarding visual studio and the use of random. If i run the following code in the linux based ubantu, or even just using CMD a random number is produced everytime. However, when using visual studio code the number 3 is constantly returned in a sample size of 10 attempts. Does anyone know why this is happening or if visual studio code just doesnt support the use of random for C++? This is is definetly an issue with visual studio code.

#include <iostream>
#include <random>
int main()
{
std::random_device random_device;
std::mt19937 engine{random_device()};
std::uniform_int_distribution<int> dist(0, 6);

int random_index = dist(engine);
std::cout << "This is a random number" << random_index;

    return 0;
}



Aucun commentaire:

Enregistrer un commentaire