VS2017使用中的time(),配合srand,rand出错,如何解决?

VS2017使用中的time(),配合srand,rand出错

int main()
{
srand(time(0));
int a = rand() % 10;
std::cout << a << std::endl;

return 0;

}

运行结果及详细报错内容

img

std::srand

#include<time.h>
#include<stdlib.h>
#include<iostream>
int main()
{
::srand((unsigned int)::time(NULL));
int a = ::rand() % 10;
std::cout << a << std::endl;
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
  srand(time(0));
  int a = rand() % 10;
  cout << a << endl;
  return 0;
}