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 the difference between these initializations? Char a[]=”string”; Char *p=”literal”; Does *p++ increment p, or what it points to?
What is meant by type casting?
Can we change the value of constant variable in c?
Explain what are multidimensional arrays?
to find the closest pair
How can I find out how much free space is available on disk?
name the language for writing c compiler?
say the following declaration is correct nr not. int b=a,n=0;
Not all reserved words are written in lowercase. TRUE or FALSE?
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
#include<stdio.h> main(0 { printf("\n %d %d %d",sizeof(3),sizeof("3"),sizeof(3)); }
What is an object?