|
-
October 19th, 2005, 07:11 AM
#1
size of pointer
In turbo C sizeof(pointer)....shows 2 bytes.....whereas in VC6.0 it shows 4 bytes...so does it means it is compiler dependent.......i guess it is......somewhere i read.....i don't remember that...size of pointer is atleast equal to unsigned int or unsigned long int(don't remember which of them)....plz help
Appreciate others by rating good posts
"Only buy something that you'd be perfectly happy to hold if the market shut down for 10 years." - Warren Buffett
-
October 19th, 2005, 07:28 AM
#2
Re: size of pointer
It's architecture dependent. AFAIR, there's nothing in the standard that specifies the size of a pointer with respect to the size of any other type.
Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
-- Sutter and Alexandrescu, C++ Coding Standards
Programs must be written for people to read, and only incidentally for machines to execute.
-- Harold Abelson and Gerald Jay Sussman
The cheapest, fastest and most reliable components of a computer system are those that aren't there.
-- Gordon Bell
-
October 19th, 2005, 07:34 AM
#3
Re: size of pointer
Turbo C targets 16 bit enviornments, so uses 16 bit (two byte) pointers (welcome back days of Segment ffset). VC6 targets primarily 32 bit enviornments, and uses 32 bit (four byte) pointers.
-
October 19th, 2005, 07:48 AM
#4
Re: size of pointer
A Beginner's Guide to Pointers
The size of a pointer is 2 bytes on 16 bits platform, and 4 bytes on 32 bit platforms.
-
October 19th, 2005, 09:59 AM
#5
Re: size of pointer
Well i tested on turbo C compiler it showed 2 bytes....in VC 6.0 it showed 4 bytes.....on the same system(32-bit).....is that because in turbo c pointers are by default near pointers....
Appreciate others by rating good posts
"Only buy something that you'd be perfectly happy to hold if the market shut down for 10 years." - Warren Buffett
-
October 19th, 2005, 10:17 AM
#6
Re: size of pointer
 Originally Posted by sunnypalsingh
Well i tested on turbo C compiler it showed 2 bytes....in VC 6.0 it showed 4 bytes.....on the same system(32-bit).....is that because in turbo c pointers are by default near pointers....
It doesn't matter what system you run Turbo C on -- it won't magically change pointer size because you're running the ancient (more than 15 years old) Turbo C program on a modern 32-bit Windows OS.
Those "near" and "far" pointers were used in 16-bit MSDOS environments, and the Turbo C compiler is made to compile 16-bit MSDOS programs. If you changed something called the "memory model" when compiling to the "Large Model", you will see by default the pointers contain both segment and offset, making them 32-bits wide. Regardless, the program that is produced will (and always will be) a 16-bit MSDOS program when using Turbo C.
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|