With an array of a certain type of element. Is there a way to use lfind to retrieve the index of an element instead of a pointer to the element?
Share
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.
You have that with the pointer.
Subtract the start of the array from the returned pointer – that’s the index.
Edit to explain more, just in case:
When you declare an array
foowithout an index is a pointer to the first elementSo if I have a pointer to an element in the array
I can get the index with: