Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


why arithmetic operation can’t be performed on a void pointer?



why arithmetic operation can’t be performed on a void pointer?..

Answer / vadivel t

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

Post New Answer

More C Interview Questions

Mention four important string handling functions in c languages .

0 Answers  


What is the stack in c?

0 Answers  


What is LINKED LIST? How can you access the last element in a linked list?

0 Answers   ADP,


What are the standard predefined macros?

0 Answers  


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?

0 Answers  


What is difference between array and pointer in c?

0 Answers  


How to print "I Love My India" without using semi colon?

4 Answers  


c program to input values in a table(using 2D array) and print odd numbers from them

1 Answers  


What are volatile variables in c?

0 Answers  


how to find sum of 5 digits in C?

4 Answers  


write a program for the normal snake games find in most of the mobiles.

0 Answers   Accenture, Wipro,


Differentiate between the expression “++a” and “a++”?

0 Answers  


Categories