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 |
write a c program to find largest of three numbers using simple if only for one time.
In C program, at end of the program we will give as "return 0" and "return 1", what they indicate? Is it mandatory to specify them?
what is the difference b/w compiler and debugger?
how to find the given number is prime or not?
Is null valid for pointers to functions?
What is the difference between arrays and pointers?
main difference between c and c++ language
Explain about the constants which help in debugging?
What's wrong with "char *p = malloc(10);" ?
write a program which counts a product of array elements lower than 10.
here is a link to download Let_Us_C_-_Yashwant_Kanetkar
Write a C program to read the internal test marks of 25 students in a class and show the number of students who have scored more than 50% in the test. Make necessary assumptions.