Pointer Increments & Scale Factor



Pointers can be incremented like.

p1=p1+1;

p1=p2+2; &so on.

The expression  like p1++;

Will cause the pointer p1 to point to the next value of its type. For ex. If p1 is an integer pointer with an initial value, say 2800, then after with an initial value, the value of p1 will be 2902, & not 2801.

i.e., when we increment a pointer, its value is incremented by the length of the data type that it points to . This length is called the scale factor.

The no of bytes used to store various data types depends on the system & can be  found by making use of the size of operator.

Character 1 byte
Integers 2 bytes
Floats 4 bytes
Long integers 4 bytes
Double  8 bytes

Related

C Language 2892278418220282206

Post a Comment

emo-but-icon

item