I have the following program that prints 4. I am running this program on Windows 7 64-bit. Shouldn't it print 8 for 64-bit platform? Thanks in advance.
#include <stdio.h>
void main()
{
printf("%d", sizeof(void*));
}
When you use a compiled language such as C, the size of the pointer is not determined by the platform on which you are running your code: it depends only on the platform for which you have compiled your code.
Windows 7 64-bit can run code compiled for 32-bit platforms. Judging by the output of your program, it appears that your code has been compiled for Win-32.
In Visual Studio 2010, to to the properties page of your C/C++ project, and make sure that Active (x64)
is selected in the "Platform" drop-down (it's Win32 by default). If x64
is not available in the dropdown, click [Configuration Manager...]
, and choose x64
for the platform of your project. If a "Copy from..." dialog opens, click [OK]
to dismiss it. The program should run in 64-bit mode after a recompile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With