CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.

Sponsored Links

Interview Questions
Our Services



INTERVIEW QUESTIONS C OPERATORS IN C DETAILS
Question :

What is a const pointer?

Category Operators in C Interview Questions
Rating (3.7) By 16 users
Added on 10/22/2009
Views 4045
Rate it!


Answers:

Source: CoolInterview.com

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 */
Source: CoolInterview.com



Source: CoolInterview.com


const pointer: pointer is a constant which points the address of another variable

we can't change the pointer(or
otherwords can't change the
address, pointer points to)

char c[100]="Hello";
char d[100]="Human";
char *const ptr=c; //ptr points c
ptr=d;/* Illegal*/
ptr[3]='Y'; /* Legal*/

pointer to const: The address pointed by pointer is constand that means we can't change the const location value using pointer

char c[100]="Hello";
char d[100]="Human";
const char *p=c;
p[2]='M'; /* Illegal */
p=d; /* Legal */


VENKATGOPU
Source: CoolInterview.com



Posted by: VENKATGOPU

Contact VENKATGOPU Contact VENKATGOPU

If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
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 a type cast not be used?
View Answer
Can math operations be performed on a void pointer?
View Answer
What is a modulus operator? What are the restrictions of a modulus operator?
View Answer
Why n++ executes faster than n+1?
View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View ALL Operators in C Interview Questions & Answers



User Options
India News Network

Latest 20 Questions
What is XML Element?
What is CDATA?
Who is responsible for XML?
What is an XML Schema?
What is well formed XML document?
Why XML has been used for development?
What is SGML?
What are the special characters used in XML?
What are the disadvantages of XML?
Why XSLT is important for XML?
What are nested elements in XML?
What is XQuery?
What is XLink and XPointer?
Why XML editor is needed instead of Notepad?
What is XML Encoding?
Which XML is set to be valid XML?
What is Simple Element?
What is Complex Element?
Is there a way to describe XML data?
What are the three parts of XSL?



Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |




Copyright ©2003-2016 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions



Cache = 0.515625 Seconds