c - How is a string literal equal to char*, and how should I take a string as a parameter -
i have seen in several pieces of code string declared char*. how work, surely pointer single char, not array of chars makes string. if wished take string input method called this:
themethod("this string literal");
what datatype should parameter be?
surely pointer single char, not array of chars
it's pointer first character of array of char
. 1 can access each element of array using pointer first element performing pointer arithmetic , "array" indexing.
what datatype should parameter be?
const char *
, if don't wish modify characters within function (this general case), , char *
if do.
Comments
Post a Comment