why arithmetic operation can’t be performed on a void pointer?
Hav an example with an int pointer,
assume compiler allocates two bytes for an int.
int *iptr, iArray[3] = {1, 2, 3};
/*say the iArray starting address would be 1000*/
iptr = iArray[0];
/*When u r trying to do iptr++ then it will point to 1002
(two bytes for an int) where element 2 available.
cos compiler knows how many bytes has two increment*/
iptr++;
Now come to void:
void pointer is generic pointer which can be point to any
kind of data types.
void *ptr;
/*When u r trying to do ptr++, since it is void pointer, it
will not know exactly how many bytes has to be incremented.
So that arithmatic operations not possible with void
pointer.*/
| Is This Answer Correct ? | 4 Yes | 0 No |
What is hashing in c language?
what are non standard function in c
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above
Why do we use int main?
Sir i need notes for structure,functions,pointers in c language can you help me please
What is property type c?
What is #line?
Read N characters in to an array . Use functions to do all problems and pass the address of array to function. 2. Enter alphanumeric characters and form 2 array alphaets and digits.Also print the count of each array.
Describe the modifier in c?
What will be the outcome of the following conditional statement if the value of variable s is 10?
Explain #pragma statements.
What is the purpose of 'register' keyword?