CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C DETAILS
Question :
What is a const pointer?
Category C Interview Questions
Rating (3.9) By 10 users
Added on 10/22/2004
Views 3950
Rate it!
Answers:

The access modifier keyword const is a promise the programmer makes to the compiler that the value of a variable will not be changed after it is initialized. The compiler will enforce that promise as best it can by not enabling the programmer to write code which modifies a variable that has been declared const.

A ?const pointer,? or more correctly, a ?pointer to const,? is a pointer which points to data that is const
(constant, or unchanging). A pointer to const is declared by putting the word const at the beginning of the pointer declaration. This declares a pointer which points to data that can?t be modified. The pointer itself can be modified. The following example illustrates some legal and illegal uses of a const pointer:

const char *str = ?hello?;
char c = *str /* legal */
str++; /* legal */
*str = ?a?; /* illegal */
str[1] = ?b?; /* illegal */





If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
When should the register modifier be used? Does it really help?
View Answer
when should the volatile modifier be used?
View Answer
Can a variable be both const and volatile?
View Answer
How reliable are floating-point comparisons?
View Answer
How can you determine the maximum value that a numeric variable can hold?
View Answer
When should a type cast be used?
View Answer
When should a type cast not be used?
View Answer
Is it acceptable to declare/define a variable in a C header?
View Answer
What is the difference between declaring a variable and defining a variable?
View Answer
Can static variables be declared in a header file?
View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/1060/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.61