Difference between const char* p, char * const ... - Tutorialspoint
文章推薦指數: 80 %
const char* const says that the pointer can point to a constant char and value of int pointed by this pointer cannot be changed. And we cannot ...
Home
CodingGround
Jobs
Whiteboard
Tools
Business
Teachwithus
TrendingCategories
DataStructure
Networking
RDBMS
OperatingSystem
Java
iOS
HTML
CSS
Android
Python
CProgramming
C++
C#
MongoDB
MySQL
Javascript
PHP
SelectedReading
UPSCIASExamsNotes
Developer'sBestPractices
QuestionsandAnswers
EffectiveResumeWriting
HRInterviewQuestions
ComputerGlossary
WhoisWho
Differencebetweenconstchar*p,char*constp,andconstchar*constpinC
CServerSideProgrammingProgramming
PointerInCprogramminglanguage,*prepresentsthevaluestoredinapointerandprepresentstheaddressofthevalue,isreferredasapointer.constchar*andcharconst*saysthatthepointercanpointtoaconstantcharandvalueofcharpointedbythispointercannotbechanged.Butwecanchangethevalueofpointerasitisnotconstantanditcanpointtoanotherconstantchar.char*constsaysthatthepointercanpointtoacharandvalueofcharpointedbythispointercanbechanged.Butwecannotchangethevalueofpointerasitisnowconstantanditcannotpointtoanotherchar.constchar*constsaysthatthepointercanpointtoaconstantcharandvalueofintpointedbythispointercannotbechanged.Andwecannotchangethevalueofpointeraswellitisnowconstantanditcannotpointtoanotherconstantchar.Thumbruleistonamingsyntaxfromrighttoleft.//constantpointertoconstantchar
constchar*const
//constantpointertochar
char*const
//pointertoconstantchar
constchar*Example(C)Uncommentthecommentederrorneouscodesandseetheerror. LiveDemo#include
延伸文章資訊
- 1[C] 每天來點字串用法(3) - from const char* to char*
由 const char* 轉成 char*. 有時候可能在將字串傳入函式時,會出現以下錯誤: error: invalid conversion from 'const char*' to '...
- 2C++中string、char *、char[]、const char*的轉換 - IT人
同時有一點需要說明,這裡在devc++中編譯需要新增const,否則會報錯invalid conversion from const char* to char *,這裡可以再前面加上const...
- 3const char - C++ Forum
- 4Difference between char* and const char*? - Stack Overflow
- 5const char * as a function parameter in C++ - Stack Overflow