Going through some piece of software written in C, I encountered the following bit of code, which I can summarize as such:
void fill_array_with_some_data(int *_)
{
// assign some arbitrary int values to _[0] and _[1]
_[0] = 42;
_[1] = 24;
}
int main(int argc, char **argv)
{
int x[2] = {0};
fill_array_with_some_data(&x[0]);
// do something with the data which is now is x
if (x[0] & 0x42)
// do something
return 0;
}
Seeing &x[0] instead of simply x seemed odd to me.
Is there any difference between both?
Is there any reason why one would want to use &x[0] rather than simply x?