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                      
Google
   
 
Categories >> Software >> Programming Languages >> C
 
 


 

 
 C interview questions  C Interview Questions (2248)
 C++ interview questions  C++ Interview Questions (1106)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (644)
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 ?    112 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
 
#include<stdio.h> #include<conio.h> void main() { int m=0111,n=20; printf("%d%d\n",m,n); getch(); }   1
parkside's triangle.. create a program like this.. enter the size: 6 enter the seed: 1 output: 1 23 456 7891 23456 789123 sample2: enter the size: 5 enter the seed: 3 output: 3 45 678 9123 45678 parkside should not exceed 10 while its seed should only be not more than 9..   4
What is the output of the following progarm? #include<stdio.h> main( ) { int x,y=10; x=4; y=fact(x); printf(%d\n,y); } unsigned int fact(int x) { return(x*fact(x-1)); } A. 24 B. 10 C. 4 D. none   2
how to make c program without a libary? e.g.#include<stdio.h> libary is not in c progaram.   2
Write a C program that defines a 2-dimentional integer array called A [50][50]. Then the elements of this array should randomly be initialized either to 1 or 0. The program should then print out all the elements in the diagonal (i.e. a[0][0], a[1][1],a[2][2], a[3][3], ..a[49][49]). Finally, print out how many zeros and ones in the diagonal. Infosys 3
what is void pointer?   1
how to add two numbers without using arithmetic operators?   4
here is a link to download Let_Us_C_-_Yashwant_Kanetkar Microsoft 3
How do you write a program which produces its own source code as its output?   2
what type of language is C? Microsoft 8
Explain in detail how strset (string handling function works )pls explain it with an example.   1
i want to have a program to read a string and print the frequency of each character and it should work in turbo c Persistent 3
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com