Answer the question
In order to leave comments, you need to log in
What is the difference between char* and int*, float* and others in C?
Programming is something new for me, I learn the basics from lectures. And, I don’t understand, if the asterisk (*) is a pointer, then how does a pointer to int differ from a pointer to char? Yes, they [char and int] differ from each other. But if the file is only a pointer, then how will a pointer to char differ from a pointer to int? It will still be something like 0xXXXXXX...
Answer the question
In order to leave comments, you need to log in
The pointer size is the same, if that's what you mean.
char* differs from int* in that the former points to a memory area of sizeof(char) bytes, and the latter to 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;
A pointer is a variable that stores the address of one byte in memory. Often the address itself is called a pointer, because the address itself is usually not used and only implies what is at this address (therefore, they became synonymous).
By one address, you cannot tell how many bytes there can be considered as a whole, since the address itself provides information about only one byte. Therefore, the pointer has a type, which means that at that address there are so many bytes that must be considered as a single whole.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question