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

differentiate between
const char *a;
char *const a; and
char const *a;

Answer Posted / shaista naaz

char * a = "Hello world";
1)
we cannot make a[i] = 'Some character'. This is not allowed.
but we can make
a = "Hi world";
that is char * a is basically a is a pointer which can point
to different address like when we say
a = "Hello world" and then we say a = "Hi world";
Here a is pointing to different address bit as I said before
If we try a[i] = 'some char' will give compiler error as
because here the string is constant not pointer so this is
const char * a = a is a pointer which is pointing to a
constant string. This is a default behaviour.
2)
char * const a = "I am good" ;
Now here you cannot do any thing no modification allowed.
Try doing a[0] = 'Y';
it fails.
Try doing a = "You are good";
It fails too
Error is You cannot assign to a variable which is a constant.
So a is a variable which is a pointer to character and is
constant.
or a is a constant pointer to character.
3)
char const * a = const char *a
As in both the case a is a pointer to character which is
constant and a can point to different string but this string
itself cannot be modified. This is the default behavior of
char * a.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor

1053


Difference between pass by reference and pass by value?

1107


What is the purpose of the statement: strcat (S2, S1)?

1116


When should structures be passed by values or by references?

1004


how many key words availabel in c a) 28 b) 31 c) 32

1019


Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?

1090


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1171


to find the closest pair

2294


What is the usage of the pointer in c?

1060


What are 'near' and 'far' pointers?

992


Do you know the use of fflush() function?

1018


An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

1120


What is pointers in c with example?

1029


What is advantage of pointer in c?

1132


Why doesnt the call scanf work?

1146