在C / C C-字符串定义++ [英] C-string definition in C / C++
问题描述
真的词C字符串,在C / C的意思++?字符指针?字符数组?或字符常量可能指针/常量数组?
What really means by word "C-string" in C / C++? Pointer to char? Array of characters? Or maybe const-pointer / const array of characters?
推荐答案
一个C字符串是用0(空字符)字节结束的字符数组。该数组,而不是任何指针,是的字符串的。因此,C字符串的任何终端子阵也是一个C字符串。类型的指针的char *
(或为const char *
等)通常被认为是指向字符串,但他们实际上会指向一个字符串的元素,通常作为指针的初始的字符串的元素处理。
A "C string" is an array of characters that ends with a 0 (null character) byte. The array, not any pointer, is the string. Thus, any terminal subarray of a C string is also a C string. Pointers of type char *
(or const char *
, etc.) are often thought of as pointers to strings, but they're actually pointers to an element of a string, usually treated as a pointer to the initial element of a string.
这篇关于在C / C C-字符串定义++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!