answersLogoWhite

0


Best Answer

Because 32 bit is exactly four bytes.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why pointer variable size of is 4bytes in 32 bit compiler?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the size of null pointer?

A NULL pointer has the same size as a non NULL pointer. NULL means that the pointer has been set to the NULL value that is usually zero (0) but the NULL value is at the digression of the compiler manufacture (and may have a value other than zero) so a pointer should always be set to the NULL value and not zero. Current compilers (32 and 64 bit, Intel chip) have a pointer size of 4 (8 bit) bytes. It should be noted that the number of bits in any data type is at the compiler manufactures digression but is heavily influenced by the computer hardware. void *p= NULL; printf ("%d\n", sizeof (p)); or printf ("%d\n", sizeof (void *));


What kind of information is represented by a pointer variable?

It is variable. On most PCs it is either 32 or 64 bits. But it can be smaller on other systems. To find the size use sizeof(void*) .


Explain pointer of any data type that requires four bytes?

When a pointer to a data type that requires four bytes is declared, the compiler knows that the target object is four bytes in size. When the program then performs a calculation to offset the pointer, such as to add 3 (for instance) to the pointer, the generated code actually adds 12. This is because the compiler assumes that adding or subtracting numbers to or from a pointer is an attempt to use the pointer in an array context. (Actually, this behavior is defined in the language specification.)The other valid arithmetic manipulation of a pointer is subtraction of two pointers to the same type of object. In this case, again, an internal multiplier of 4 is applied, and the result is an offset that could be used if the first pointer were the base of an array of those objects.The size of the target object could be any value, such as a double which might be 8 bytes. The compiler will do the arithmetic correctly.Also, keep in mind the distinction between the size of the pointer and the size of the object to which the pointer points. This answer assumes the latter.In any case, the programmer must insure that the calculation results in a pointer or offset value that represents an address in the base object array, assuming that the allocated space of that object is correct. Any other result is inconsistent with the defined usage of a pointer, and the result of dereferencing such an inconsistent pointer or offset is undefined by the language specification, and could result in corruption, incorrect behavior, or crash.


What is the difference between initialisation and definition in C programming?

Variable-declaration is: extern int x; extern double y; extern char a; Variable-definition is: int x; static double y; auto char a; Variable-definition with initialization is: int x = 1; static double y= 2.3; auto char a = 'w';


What is the maximum integer allowed in an integer-type variable?

That varies from each programming language. As a matter of fact, many languages do not put a limit on the maximum size of a variable. It will handle any string, integer, resource, pointer, or other type size, as long as it fits into the memory of the machine running the process.

Related questions

Define pointer in C?

Pointer is a variable, A variable that stores the address of another variable. Size of a pointer is 2 bytes.


In pointers what is the use of pointer variable?

Pointer is a variable that stores the address of another variable . So pointer basically stores the address of another variable and size of pointer can be evaluated by using sizeof operator.


What is the difference bw function pointer and function of pointer?

function pointer is a variable that hold the address of any function which declared in the program but function pointer is the array of the function that accept the run time size of the function.


How many types of pointers are there?

That depends on what you consider a type. A pointer variable simply stores a memory address or NULL so, strictly speaking, there is only one type of pointer. A pointer variable's type (int *, char *, void *, etc) determines the type that a pointer points to, not the type of the pointer itself. Whether a pointer points to a primitive type, a user-defined type, a function, another pointer or void, makes no difference to the pointer variable itself. It simply stores a memory address. How you treat that memory address is determined by the pointer variable's type. So, in that respect, there are as many types of pointer as there are types to point at; which would be infinite. The architecture determines the size of a pointer variable. On a 16-bit system, a pointer will occupy just 2 bytes, while on a 32-bit system it occupies 4 bytes and 8 bytes on a 64-bit system. Although these may be considered separate pointer types, you can't pick and choose which type you use. The size must be consistent for any given architecture, hence the prevalent use of the sizeof() operator to determine a variable's length at runtime.


What is the size of null pointer?

A NULL pointer has the same size as a non NULL pointer. NULL means that the pointer has been set to the NULL value that is usually zero (0) but the NULL value is at the digression of the compiler manufacture (and may have a value other than zero) so a pointer should always be set to the NULL value and not zero. Current compilers (32 and 64 bit, Intel chip) have a pointer size of 4 (8 bit) bytes. It should be noted that the number of bits in any data type is at the compiler manufactures digression but is heavily influenced by the computer hardware. void *p= NULL; printf ("%d\n", sizeof (p)); or printf ("%d\n", sizeof (void *));


What kind of information is represented by a pointer variable?

It is variable. On most PCs it is either 32 or 64 bits. But it can be smaller on other systems. To find the size use sizeof(void*) .


Explain pointer of any data type that requires four bytes?

When a pointer to a data type that requires four bytes is declared, the compiler knows that the target object is four bytes in size. When the program then performs a calculation to offset the pointer, such as to add 3 (for instance) to the pointer, the generated code actually adds 12. This is because the compiler assumes that adding or subtracting numbers to or from a pointer is an attempt to use the pointer in an array context. (Actually, this behavior is defined in the language specification.)The other valid arithmetic manipulation of a pointer is subtraction of two pointers to the same type of object. In this case, again, an internal multiplier of 4 is applied, and the result is an offset that could be used if the first pointer were the base of an array of those objects.The size of the target object could be any value, such as a double which might be 8 bytes. The compiler will do the arithmetic correctly.Also, keep in mind the distinction between the size of the pointer and the size of the object to which the pointer points. This answer assumes the latter.In any case, the programmer must insure that the calculation results in a pointer or offset value that represents an address in the base object array, assuming that the allocated space of that object is correct. Any other result is inconsistent with the defined usage of a pointer, and the result of dereferencing such an inconsistent pointer or offset is undefined by the language specification, and could result in corruption, incorrect behavior, or crash.


What is the difference between initialisation and definition in C programming?

Variable-declaration is: extern int x; extern double y; extern char a; Variable-definition is: int x; static double y; auto char a; Variable-definition with initialization is: int x = 1; static double y= 2.3; auto char a = 'w';


Can be used to draw a proposed tables size?

pencil pointer


What is the role of pointer variable in data structures?

Structures are a type of variable, just as int and char are types of variable. All variables of the same type have one thing in common: their size is always the same. Typically, an int is 4 bytes, and a short is 2 bytes while a char is 1 byte. So a structure with 2 ints is therefore 8 bytes in length. A structure with an int and a char is 5 bytes, but structure member alignment will typically round this up to the nearest 4 bytes, padding any unused bytes (dependant upon your compiler's member alignment options). Regardless, a structure's size is known in advance by the number and type of its member variables. It's size is fixed. This is important when creating arrays of structures because every element in the array must be same size, and the size must be known in advance. This then makes it impossible to store variable length strings and other dynamic arrays within a structure. That is where pointer variables come in. Since all they store is a memory address, pointer variables are a fixed size (4 bytes on a 32-bit system). It really doesn't matter how much memory is allocated to that memory address, because that memory is not physically part of the structure -- only the pointer variable itself is a member of the structure. The pointer variable simply "points" to the memory address stored in it, and the type of the pointer determines how that memory is accessed, whether it is a pointer to a primitive variable type, an array of char or an array of another structure altogether. Ultimately, the structure is only concerned with the pointer variable, not what it points at. This then allows your structures to make better use of memory. There is no need to allocate an array far larger than you actually need, simply to cater for the "worst-case". Other uses for pointers within structures include the ability to point at other structures of the same type, such as is required in linked lists. You cannot do this with references because the reference must be completely defined in advance; a structure that references its own type would require infinite memory because that reference contains another reference, which contains another reference... But it can point at another instance of the structure, including itself, because pointers only need to be declared, not completely defined. The same applies to classes with member pointer variables. The only difference is that structures have public access by default while classes have private access by default. But classes can point to structures and vice versa. Apart from that, classes are just like any other variable type; they are a fixed size.


What is the maximum integer allowed in an integer-type variable?

That varies from each programming language. As a matter of fact, many languages do not put a limit on the maximum size of a variable. It will handle any string, integer, resource, pointer, or other type size, as long as it fits into the memory of the machine running the process.


What is The header of an IPv4?

Header is always a multiple of 4bytes and so we can have a maximum length of the field as 15, so maximum size of the header is 60 bytes out of which 20 bytes are mandatory.