In C, is there a difference between the following declarations:
float DoSomething( const float arr[] );
Vs.
float DoSomething( const float* arr );
Is one preferable than the other?
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.
No, there isn’t any difference. An array is decayed into a pointer whenever it is passed as an argument to a function.
I think that using the array syntax is a bit clearer, it gives a hint that it is an array and not just a pointer to one object.
There is a quite detailed description of pointers and arrays at http://www.c-faq.com/aryptr/index.html.