I wanna read random bytes and fill into byte array as the random numbers generator. And then I want to call this in C#. My codes look below (C++ in VS2015):
#include<iostream>
using namespace::std;
void main()
{
unsigned char *pointer = (unsigned char*)malloc(0);
unsigned char *writer = pointer;
for (int i = 0; i < 10; i++)
{
cout << (unsigned short)(*writer) << endl;
writer += sizeof(writer);
}
free(pointer);
system("pause");
}
There's a very strange problem. Each time I run the console app, the first 2 bytes are ALWAYS the same. But in my mind I hope that each time I run the app, the result is NOT the same.
So:
1) Is my algorithm right?
2) How to solve this?
3) Can I wrap this by exporting it to dll and then call it in the C#? How to do with that?
Aucun commentaire:
Enregistrer un commentaire