ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
   
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
what is the difference between
const char *p, char const *p, const char* const p
 Question Submitted By :: Rajesh
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what is the difference between const char *p, char const *p, const char* const p
Answer
# 1
const char*p - p is pointer to the constant character i.e
value in that address location is constact

char const *p - same as above

const char* const p - p is the constant pointer which
points to the constant string, both value and address are
constants
 
Is This Answer Correct ?    111 Yes 48 No
Singamsa
[Virtusa]
 
  Re: what is the difference between const char *p, char const *p, const char* const p
Answer
# 2
CONST char *p:
here the const. keyword is coming before the data
type... so the string here will be the constant but not he
pointer...
char CONST *p:
here also the string will be the constant but not the
pointer...
CONST char* CONST p:
here both , the string as well the pointer will be constant
 
Is This Answer Correct ?    63 Yes 31 No
Vignesh1988i
 
 
 
  Re: what is the difference between const char *p, char const *p, const char* const p
Answer
# 3
CONST char *p;
here the const. keyword is coming before the "*p"
So it affects the value pointed by "p" i.e. "*p"
You can't change the character (value pointed by p).
Although you can change the address stored in "p".

char CONST *p;
same explanation as above

char * CONST p;
here the const. keyword is coming before the "p" and
after "*" So it affects the value of "p" (which holds
the address). You can't change the address stored in
"p". Although you can change the value pointed by p
i.e. "*p"

CONST char* CONST p:
here CONST is coming before the "*" as well as after
the "*". Therefore, as expeected neither the address
of nor the value pointed by "p" can be changed.
 
Is This Answer Correct ?    164 Yes 10 No
Kumar Krishna
 
  Re: what is the difference between const char *p, char const *p, const char* const p
Answer
# 4
Const char *P ->
declares a pointer through which you may be able to access
a char but you can not change it through the said pointer.
But the pointer itself can be changed.

char const *p ->
in this the value is constant

const char* const p ->
both address and value are constants
 
Is This Answer Correct ?    12 Yes 21 No
Bhargav
 
  Re: what is the difference between const char *p, char const *p, const char* const p
Answer
# 5
In a const char *p the chrac pointed by 'p' is a const, so
u cant change the value of the charac ponted by 'p', but u
can make 'p' refer to some other location.

In a char const *p, the ptr 'p' is constant not the
character refered by it, so u can not make 'p' refer to
anyother location, but u can change the value of the charac
pointed by 'p'
 
Is This Answer Correct ?    9 Yes 3 No
Magdaleen
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
write a statement to display all the elements array M(in reverse order? int M[8]={20,21,22,23,24,25,26,27};  5
I have a function which accepts, and is supposed to initialize,a pointer, but the pointer in the caller remains unchanged.  1
wite a programme in c to linear search a data using flag and without using flags? TCS3
What is RAM memory? and What is ROM?Who designed one is temparary and another is permanent?why they designed like that?By using far pointer which type data(whether hexadecimal)we can access? Excel1
program to find the second largest word in a paragraph amongst all words that repeat more thn twice iGate4
write a program to display numbers from 1 to 10 and 10 to 1?  2
which of the function operator cannot be over loaded a) <= b)?: c)== d)* HCL10
write a program structure to find average of given number  1
AMMONG THE 4 STROAGE CLASSES IN C, WHICH ONE FASTEST? HCL13
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys. Subex1
who is the father of C Language? CTS19
what wud be the output? main() { char *str[]={ "MANISH" "KUMAR" "CHOUDHARY" }; printf("\nstring1=%s",str[0]); printf("\nstring2=%s",str[1]); printf("\nstring3=%s",str[2]); a)string1=Manish string2=Kumar string3=Choudhary b)string1=Manish string2=Manish string3=Manish c)string1=Manish Kumar Choudhary string2=(null) string3=(null) d)Compiler error Infosys8
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2012  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com