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

what is the difference between these initializations? Char a[]=”string”; Char *p=”literal”; Does *p++ increment p, or what it points to?

4 Answers  


What is meant by type casting?

0 Answers  


Can we change the value of constant variable in c?

0 Answers  


Explain what are multidimensional arrays?

0 Answers  


to find the closest pair

0 Answers   Infosys,


How can I find out how much free space is available on disk?

0 Answers  


name the language for writing c compiler?

3 Answers   Microsoft,


say the following declaration is correct nr not. int b=a,n=0;

4 Answers   Wipro,


Not all reserved words are written in lowercase. TRUE or FALSE?

0 Answers  


How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

0 Answers  


#include<stdio.h> main(0 { printf("\n %d %d %d",sizeof(3),sizeof("3"),sizeof(3)); }

4 Answers   HCL,


What is an object?

5 Answers  


Categories