AraK
February 10th, 2008, 09:47 PM
Hi,
this is my first post in this great forum.
I needed to produce an array of random numbers. so I decided to dumb the array to a file for testing purpose only. I used this function :
void GeneratePass( const char* passPath, size_t units ){
std::ofstream passFile;
size_t *pass = new size_t[units];
srand( __time32_t(NULL) );
for( size_t C = 0; C < units; C++ )
pass[C] = rand();
passFile.open( passPath, std::ios::binary );
passFile.write( reinterpret_cast<char*>(&pass), units * sizeof(size_t) );
passFile.close();
delete[] pass;
return;
}
I opened the file using Notepad++ to see the file in hex mode, I got repeated values :
http://up3.m5zn.com/uploads/611b12dde8.gif
and I got something strange :
http://up3.m5zn.com/uploads/bfe96b9f2f.gif
could someone please explain what's happening ??!!!
I am using VC++ 2008 Express, WinXP SP2.
Thanks..
this is my first post in this great forum.
I needed to produce an array of random numbers. so I decided to dumb the array to a file for testing purpose only. I used this function :
void GeneratePass( const char* passPath, size_t units ){
std::ofstream passFile;
size_t *pass = new size_t[units];
srand( __time32_t(NULL) );
for( size_t C = 0; C < units; C++ )
pass[C] = rand();
passFile.open( passPath, std::ios::binary );
passFile.write( reinterpret_cast<char*>(&pass), units * sizeof(size_t) );
passFile.close();
delete[] pass;
return;
}
I opened the file using Notepad++ to see the file in hex mode, I got repeated values :
http://up3.m5zn.com/uploads/611b12dde8.gif
and I got something strange :
http://up3.m5zn.com/uploads/bfe96b9f2f.gif
could someone please explain what's happening ??!!!
I am using VC++ 2008 Express, WinXP SP2.
Thanks..