I asked this on Taking an index out of const char* argument along with another question, but debate got only to the first question, so I splitted it to a different thread.
Question:
Is there any reason anyone would ever want to represent a C string as and not as ? 而不是吗?
Thanks,
Yes, of course a general read-only string should be const char *
, since char
(with unspecified implementation-specified signedness) is the default type for a character.
In other words, a literal like "foo"
consists of char
, not unsigned char
, elements.
Of course you can interpret the characters as unsigned if you feel like it, but then you might need a cast.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.