Question reguarding pointers/hexadecimal

I inherited some code for a project I'm working on and I am trying to read through and understand it. I have two questions regarding pointers because the code uses them often. I've done my best to use C++ resources on pointers but I was unable to resolve the following two questions.

  1. How is "Mag" accepted as a parameter when I2Cread requires a pointer? Shouldn't "&Mag" be passed instead?

  2. What is while "(!(ST1&0x01))" saying? From my understanding "&" turns a variable into a pointer when it precedes said variable. So why does it follow ST1? Does it have something to do with hexadecimal?

Below is the code: First is the method I am referring to which is then followed by method calls that appear later on in the code (In the actual code they do not follow that method immediately).

Thank you.

edit: fixed typo in the code

// This function read Nbytes bytes from I2C device at address Address. 
// Put read bytes starting at register Register in the Data array. 
void I2Cread(uint8_t Address, uint8_t Register, uint8_t Nbytes, uint8_t* Data)
  // Set register address
  // Read Nbytes
  Wire.requestFrom(Address, Nbytes); 
  uint8_t index=0;
  while (Wire.available()) 

uint8_t ST1;
while (!(ST1&0x01));

// Read magnetometer data  
uint8_t Mag[7];  

Mag is a reference to an array which is mostly interchangeable with a pointer.

Ampersand is overloaded. In your expression it's a bitwise-and.

passing ‘Mag’ is the same as passing ‘&Mag[0]’ but a bit easier to read.

Unary '&' (used by itself in front of a variable name) gives the address of the variable.

Binary '&' (between two integer values or variables) is bitwise AND.

'while (!(ST1&0x01))' is saying 'repeat until the first bit of ST1 is zero'.

You missed one. What is the third purpose of ampersand?

(excluding operator overloading)

Third would be declaring a reference, but since that's TOTALLY irrelevant to the question, it's just a needless distraction.

...but since that's TOTALLY irrelevant to the question, it's just a needless distraction.

Neither of those are your decision to make. Only @johng_99 and those reading this thread can decide.

And “&&” is a logical AND (not bitwise)

…as is “and” :smiley: