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...

wats the diference btwen constant pointer and pointer to a
constant.pls give examples.

Answer Posted / surya mukherjee

//POINTER TO CONSTANT vs CONSTANT POINTER

#include<iostream.h>
#include<conio.h>

//POINTER TO CONSTANT

void f1()
{
int i=10,j=20;
const int* pi=&i;
cout<<*pi<<endl;
//*pi = 200; ERROR : CANNOT MODIFY A CONST OBJECT IN f1()
pi=&j; // IT CAN POINT ANOTHER CONSTANT
cout<<*pi<<endl;
}

//CONSTANT POINTER

void f2()
{
int i=100,j;
int* const pi=&i;
cout<<*pi<<endl;
*pi = 200; // IT CAN ASSIGN ANOTHER VALUE AT THIS ADDRESS
cout<<*pi<<endl;
//pi=&j; ERROR : CANNOT MODIFY A CONST OBJECT IN f2()
}


void main()
{
clrscr();
f1();
f2();
getch();
}

Is This Answer Correct ?    10 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is string function c?

1073


What are directives in c?

1022


What is action and transformation in spark?

1226


What are the back slash character constants or escape sequence charactersavailable in c?

1228


Why c is called a middle level language?

1160


Explain what are linked list?

1090


What are type modifiers in c?

1095


the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above

1304


What is c token?

1121


What is function pointer c?

1188


What is the use of define in c?

1103


Explain can the sizeof operator be used to tell the size of an array passed to a function?

1115


cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration

1152


What is f'n in math?

1135


How many types of operator or there in c?

1137