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

Explain how can I avoid the abort, retry, fail messages?

0 Answers  


What is methods in c?

0 Answers  


1. Write a program to reverse every second word in a given sentence.

1 Answers  


What is the function of multilevel pointer in c?

0 Answers  


Explain what is a 'locale'?

0 Answers  


what do u mean by Direct access files? then can u explain about Direct Access Files?

0 Answers   LG Soft,


In a switch statement, what will happen if a break statement is omitted?

0 Answers  


write a program for size of a data type without using sizeof() operator?

22 Answers   HCL, IBM,


How can I invoke another program from within a C program?

8 Answers  


can you change name of main()?how?

3 Answers   HCL, Siemens,


Explain Linker and Loader

5 Answers  


write a program to find lcm and hcf of two numbers??

1 Answers  


Categories