Why string is a char*?

Another question on a different char* from, int*, float* and others in si? .
As far as I know, string is a character string (many characters, in short).
Char is one character, character type. Obviously, for string memory need much more. So why char* is a string, and why there is an asterisk (*) ?
July 8th 19 at 16:34
3 answers
July 8th 19 at 16:36
Solution
I so understood that std::string is not meant.
That is, the real question is this: why strings are passed as char*, although this is the type of the pointer to one char.

The fact that arrays in C cannot be passed as a function parameter, a pointer to an array cannot be saved.
As a result, the array for example char[8], made to pass as a pointer to its first element: char*. Moreover, when passing an array to a function, it automatically decays (decays) to a pointer to the first element.

The remaining elements are obtained using pointer arithmetic: *(p+3) or p[3], which is the same thing. So, a pointer in the code C can point to one variable and a whole array (or rather, its beginning).

For arrays of int or any other type usually along with a pointer to the first element is passed size of the array. But C strings end with a null character, so the length is known and so. It turns out that char* is used instead of char[N].

Edit: actually, in C you can declare a pointer to an array:
int (*arr)[10] = malloc(sizeof(*arr) * 5);
I don't remember I saw such a design in real code.
in si there are no rows, std::string is C++ - Sterling_Farre commented on July 8th 19 at 16:39
July 8th 19 at 16:38
July 8th 19 at 16:40
You have in the tags is the language C. it is not of type string. Not at all.
What is asterisk, you can read a book on C, it should be on the first pages.

With is a very simple language you can call it a cross-platform assembler. And because of its simplicity and minimalism and it has become so popular.
The fact that study course CS50, and there was given its own library in the beginning where, char* what string, and some commands, like GetString(); which reads what the user entered and stores into a variable, checking for all kinds of errors. - Sterling_Farre commented on July 8th 19 at 16:43
mirror.cs50.net/library50/c/cs50-library-c-3.0/cs50.h
typedef char *string;

They why-that have defined an alias for char * as a string. - Julien.Kiehn90 commented on July 8th 19 at 16:46

Find more questions by tags C