I have a pointer (uint8_t *myPointer), that I pass as parameter to a method, and then this method sets a value to this pointer, but I want to know how many bytes are used (pointed at ?) by the myPointer variable.
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The size of the pointer:
sizeof(myPointer)(Equal tosizeof(uint8_t*))The size of the pointee:
sizeof(*myPointer)(Equal tosizeof(uint8_t))If you meant that this points to an array, there is no way to know that. A pointer just points, and cares not where the value is from.
To pass an array via a pointer, you’ll need to also pass the size:
You can use a template to make passing an entire array easier: