Hi, im trying to create a file mapped object, creating it works fine, and using lstrcpy i can copy characters to the file object with no problems. However, when i use memcpy I run into problems. This is the exact code I am using in Dev-Cpp and it works bueatifully
Code:
int main(int argc, char *argv[])
{
int error = 0;
initialize();
TCHAR s1[5] = {1,2,3,4,5};
switch (error)
{
case 0:
{
if ( WaitForSingleObject(m_hMutex, dwMaxWait) == WAIT_OBJECT_0 )
{
memcpy(m_pViewOfFile, s1,5);
ReleaseMutex(m_hMutex);
}
break;
}
case 4:
{
printf("yay\n");
break;
}
}
TCHAR s2[dwMemoryFileSize];
if ( WaitForSingleObject(m_hMutex, dwMaxWait) == WAIT_OBJECT_0 )
{
memcpy(s2, m_pViewOfFile, 5);
ReleaseMutex(m_hMutex);
}
for (int i = 0; i < 5; i++)
{
printf("%d ",s2[i]);
}
printf("\n");
getchar();
destroy();
return 0;
}
the console shows 1 2 3 4 5 as expected
However when I try to use this exact code in mscv (the initialization is slightly different, however it did work when i was using lstrcpy, the only thing changed is lstrcpy to memcpy) i get a rather garbled result.
1 2 52227 542428 542428
it worked fine when i was using lstrcpy, and works fine in devcpp. Anyone have any ideas.