What distinguishes char* from, int*, float* and others in si?

Programming for me - something new, learn the basics on the lectures. And, I don't know if the asterisk ( * ) is a pointer, than a pointer to int is different from a pointer to char? Yes, among themselves they [char int] differ. But if the file is only a pointer, it will differ a pointer to a char from a pointer to int? Will still be something of the form 0xXXXXXX...
July 8th 19 at 16:40
2 answers
July 8th 19 at 16:42
Solution
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.
Correction: char pc[] = "This is a string"; - kenyatta commented on July 8th 19 at 16:45
Why string is a char*? - Julien.Kiehn90 commented on July 8th 19 at 16:48
: char* pc same correctly, this is essentially the same.
Because 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
: well, then you have a const char*, otherwise you are violating const correctness - kenyatta commented on July 8th 19 at 16:54
: I agree with that. - Lucio commented on July 8th 19 at 16:57
July 8th 19 at 16:44
A pointer is a variable that holds the address of one byte in memory. And very often the address is called a pointer because the address is not commonly used and implies only what is at that address (which is why they have become synonymous).
One address you can't tell how many bytes there can be considered as a whole, because the address gives information about only one byte. Therefore, the pointer has a type that indicates that the address lies so many bytes that need to be considered as a whole.

Find more questions by tags C