Size of int and ptr in 64 bit compiler




Comment hidden because of low score. Click to expand.
0
of 0 vote

Why shouldn't it? What did you expect?

- Anonymous May 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

both the size of int and sizeof ptr is 4 byte in 32 bit machine.so why size of ptr is 8 byte in 64 bit machine

- vicky123 May 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

64bit == 8 bytes. The addressable memory space on 64-bit machine requires, well, 64bits (== 8 bytes) to specify the address of an arbitrary place in memory. Because a pointer in C/C++ has that semantics (to point to an arbitrary place in memory), its size on 64bit-machines is, well, 64-bits (aka 8 bytes).

- Anonymous June 27, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Paste Code that does so !!

- hprem991 May 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<stdlib.h>

int main()

{

int * ptr;
int x;

printf ( "sizeof ptr =%d size of int =%d ",sizeof(ptr) ,sizeof(int));

return 0;

}

on compilation:

In function ‘main’:
11:1: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat]
11:1: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat]

./a.out
sizeof ptr =8 size of int =4

- vicky123 May 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

and where did you find the difference ?? My Compiler does not show any such inconsistency and neither the online compiler ..

Check this
http: // ideone.com / XrbOu7

- hprem991 May 16, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I am working on Ubuntu Release:12.04

- vicky123 May 16, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

changed the code to printf ( "sizeof ptr =%ld size of int =%ld ",sizeof(ptr) ,sizeof(int));

Now not getting any warning but output is same
sizeof ptr =8 size of int =4

- vicky123 May 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think, you meant gcc compiler on an 64bit m/c.
You may check for the __SIZEOF_INT__ and __SIZEOF_POINTER__ predefined macros in gcc, they are independent of OS and m/c.

- ritesh May 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

AOL account setting +1-800-893-9752
It is very important to have latest and updated AOL account setting. If you are not on updated AOL account settings then you will not be able to send or receive email on your device or no matter any third party email software or client you may use.
To get latest and update setting for your AOL account you can contact AOL support on Toll-free +1-800-893-9752
contact aol member services, aol support phone number usa, aol email support phone number, aol email tech support number, aol email customer service number, aol email customer support, aol customer support telephone number, aol technical support contact number, aol com customer service phone number, download aol mail to computer, Aol email support phone number, aol gold desktop download, aol mail tech support number, aol mail hotline number, aol mail toll free number, contact aol mail support number, aol customer service number, aol support phone number, aol support number, aol mail repair

- ap2ankur May 23, 2018 | Flag Reply




Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More