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 |
Mention four important string handling functions in c languages .
What is the stack in c?
What is LINKED LIST? How can you access the last element in a linked list?
What are the standard predefined macros?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
What is difference between array and pointer in c?
How to print "I Love My India" without using semi colon?
c program to input values in a table(using 2D array) and print odd numbers from them
What are volatile variables in c?
how to find sum of 5 digits in C?
write a program for the normal snake games find in most of the mobiles.
Differentiate between the expression “++a” and “a++”?