My C++ Practices
寫程式過程的紀錄
Pages
Home
My Note
Questions
Links
Friday, March 2, 2012
指標變數 vs 常數指標
指標變數 vs 常數指標
1.
char *ptr="123456";
ptr[0]='a'; //error
//因為*ptr在此是全域常數
2.
char ptr[]="123456";
ptr[0]='a'; //ok
//因為ptr在此是區域變數
.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment