ALLInterview.com :: Home Page KalAajKal.com
 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                      
tip   SiteMap shows list of All Categories in this site.
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 ?    27 Yes 14 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 ?    17 Yes 9 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 ?    40 Yes 2 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 ?    1 Yes 6 No
Bhargav
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
what is the use of using linked list and array? Infosys9
ABCDCBA ABC CBA AB BA A A  1
study the code: #include<stdio.h> void main() { const int a=100; int *p; p=&a; (*p)++; printf("a=%dn(*p)=%dn",a,*p); } What is printed? A)100,101 B)100,100 C)101,101 D)None of the above Accenture13
What are bit fields? What is their use? Adobe1
What is false about the following A compound statement is a.A set of simple statments b.Demarcated on either side by curly brackets c.Can be used in place of simple statement d.A C function is not a compound statement. TCS1
write a program for even numbers?  8
How would you sort a linked list?  1
two variables are added answer is stored on not for third variable how it is possible?  3
what is the difference between entry control and exit control statement?  2
5. What kind of sorting is this: SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort Accenture2
without a terminator how can we print a message in a printf () function. NIIT5
Give the output for the following program. #define STYLE1 char main() { typedef char STYLE2; STYLE1 x; STYLE2 y; clrscr(); x=255; y=255; printf("%d %d\n",x,y); } ADITI1
Write a c code segment using a for loop that calculates and prints the sum of the even integers from 2 to 30, inclusive?  2
In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?  4
long int size a) 4 bytes b) 2 bytes c) compiler dependent d) 8 bytes HCL11
what is dangling pointer? LG-Soft1
what is the difference b/w compiler and debugger? Assurgent1
what is the difference between these initializations? Char a[]=”string”; Char *p=”literal”; Does *p++ increment p, or what it points to?  2
What is meant by global static? why we have to use static variable instead of Global variable L&T2
explain about storage of union elements. Bosch2
 
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 © 2007  ALLInterview.com.  All Rights Reserved.

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