Home > Back-end >  Const char * and char *
Const char * and char *

Time:05-15

Why to ask everybody, such as a series of string function STRCMP almost all added a const parameter identifier, don't add what are the consequences, because if not, if I wrote in the writing of STRCMP function 1 STR [3]='b' will lead to the main function string changed, and combined with the compiler will offer you the wrong in time, if written in ensuring function correctly is added under the condition of without no

I understand is
Const char * p: pointer point p can be changed, but the point p shall not modify the content of the
Const char * p: p points to immutable, but point p can modify the content of the
Char const * p: p points to the content of the immutable, but point p can modify

More than I understand there is an error

CodePudding user response:

Yes, that's right,
Especially when a person to write code,

And in team environment, compared to a const magnificently in the function prototype to contract in words what can't change much more concise and also more clear,

CodePudding user response:

reference 1st floor forever74 response:
yes, that's right,
Especially when a person to write code,

And in team environment, one of the function prototype const magnificently compared to convention in words what can't change much more concise and also more clear,
thank??
  • Related