a.h
struct loader_struct
{
unsigned char* loader_x64;
};
extern loader_struct* g;
a.cpp
#include "a.h"
loader_struct g_startup;
loader_struct* g = &g_startup;
b.cpp
#include "a.h"
int _tmain(int argc, _TCHAR* argv[])
{
std::string mdata = "abcdefg";
g->loader_x64 = new unsigned char[mdata.length()];
std::copy( mdata.begin(), mdata.end(), g->loader_x64 );
}
I'm trying to copy the content of mdata to loader_x64, its being copied, however, it contains some rubbish at the ending, what im doing wrong?