The pointer size is the same, if that's what you mean.
char* is different from int* the fact that the first indicates the area of memory in sizeof(char) bytes, and the second sizeof(int) bytes. This is important for example for address arithmetic.
For example, we have:
int ival[] = {0,1,2,3};
char* pc = "This is a string";
int* pi = &ival;
If we do++ pc, then pc is added sizeof(char), and in the case of pi-to pi++ adds sizeof(int).
And when we make razumevanje, we get the corresponding result type:
*pc - gives char
*pi - gives int
If it were not for typing of pointers, then there would be no address arithmetic and razumevanja. For example, look what you can do with a void pointer.
char pc[] = "This is a string";
- kenyatta commented on July 8th 19 at 16:45Because in pure C/C++ string is a character array, each element in this array is a char. A pointer to a string is a pointer to an array Sagov, a pointer to an array at the same time is a pointer to the first element of the array.
Read the book. Arithmetic of pointers is well described in www.ozon.ru/context/detail/id/2480925 after this we can take for C++ cppstudio.com/post/8439/. Arithmetic of pointers in C is entirely taken from si.
The standard library C++ has a string class, it's not something that a char*.
char* - a legacy of the si.
If you write on pure WinAPI, for example, without using libraries, strings in C style out there everywhere, and similarly in niksch, because the OS typically written in C. - Lucio commented on July 8th 19 at 16:51
a const char*
, otherwise you are violating const correctness - kenyatta commented on July 8th 19 at 16:54