skip to main | skip to sidebar

My Tech Notes

Blog programming issues I encountered.

Sunday, March 2, 2008

Constant Pointers and Pointers to Constants

1. Pointer to Constant
char char_A = 'A';
const char * myPtr = &char_A;
*myPtr = 'J'; // error - can't change value of *myPtr

2. Constant Pointer
char char_A = 'A';
char char_B = 'B';

char * const myPtr = &char_A;
myPtr = &char_B; // error - can't change address of myPtr

Posted by Xiaoguang at 5:14 PM

0 comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2009 (20)
    • ►  October (1)
      • VS2008 Remote Debugging
    • ►  September (2)
      • Enable Sql Server Authentication Mode Over Network...
      • Object.GetHashCode, Object.Equals, operator==, and...
    • ►  August (2)
      • Sql Server Script to Restore a Database
      • SQL Commands - Disable Constraints
    • ►  July (1)
      • WaitCallback method has to be static
    • ►  June (4)
      • Calling javascript from code behind
      • Calling server side method from client (using java...
      • FindControlByID
      • Using Validator as a Label
    • ►  May (3)
      • Enumerating enum
      • Accessing Data Bound to ListView
      • Javascript Code Meets Postback(full and partial)
    • ►  April (2)
      • Restoring master and msdb Database
      • Color of Source Code in Blog
    • ►  March (5)
      • javascript code not working when using updatepanel...
      • Web page gets messy in IE6
      • Setup IIS for ASP.NET projects
      • Coninental ticket number on eTicket Boarding Pass
      • Making a table scrollable
  • ▼  2008 (15)
    • ►  September (1)
      • Making Tomcat Support JSF
    • ►  August (3)
      • Show Ellipsis Text in GridView
      • Register Custom Control in Web Page
      • The Statelessness of Web Page
    • ►  July (5)
      • Building TreeView Programmably in a Recursively Fa...
      • Cannot Access Profile Property in Webpage
      • The Importance of Page.IsPostBack
      • Configuring passwordFormat="Encrypted" in ASP.NET
      • Passing Reference in C#
    • ▼  March (3)
      • Every keyCode is 229?!
      • Constant Pointers and Pointers to Constants
      • Difference between Reference and Pointer
    • ►  February (1)
      • Quotes
    • ►  January (2)
      • Add() method in .NET (passing parameter)
      • Application["UserCount"] += 1 doesn't work
  • ►  2007 (22)
    • ►  December (3)
      • What's wrong with Monitor::Enter()
      • LINK : warning LNK4075: ignoring '/EDITANDCONTINUE...
      • Visual Studio got stuck when opening sln file
    • ►  November (7)
      • Problem caused by dll loading mistake
      • Time-saving Tips
      • Mixed DLL Loading Problem
      • Be Careful of Naming
      • Examine std::vector in VS watch window
      • Why using managed extension is a pain in the ***?
      • __gc Array Aggregate Initialization
    • ►  October (1)
      • Switch between Windows debuggers
    • ►  September (1)
      • About Copy Constructor
    • ►  August (2)
      • A Key Difference Between an Assembly and an Unmana...
      • Get used to managed C++ style definition
    • ►  July (4)
      • What I've learn from COOP
    • ►  June (4)

About Me

Xiaoguang
View my complete profile