Function Problem

I've read lots about functions and passing arguments but I'm completely confused.

I want to declare a function to split a 16-bit address into two 8-bit parts. I know how to do this, having found the solution:

addr_low=curr_addr&0x00FF;
addr_high=(curr_addr>>8)&0x00FF;

So, during my attempts to find out how to do this, I wrote:

addr_low=curr_addr&0x00FF;
addr_high=(curr_addr>>8)&0x00FF;  
Serial.print("Address:");  
Serial.print(curr_addr, DEC);
Serial.print('\n');
Serial.print("High Byte:");
Serial.print(addr_high, DEC);
Serial.print('\n');
Serial.print("Low Byte:");
Serial.print(addr_low, DEC);

Result in serial monitor:
Address:3000
High Byte:11
Low Byte:184

Which proved to me the method works. I'm defining my variables before void setup() thus:

unsigned int curr_addr=3000; //Decimal address
unsigned int addr_low = 0,addr_high = 0;

What I'd like to do is declare a function like this:

void addr_to_bytes()
{
   addr_low=curr_addr&0x00FF;
   addr_high=(curr_addr>>8)&0x00FF;
}

and call it in the code like this:

addr_to_bytes();  
Serial.print("Address:");  
Serial.print(curr_addr, DEC);
Serial.print('\n');
Serial.print("High Byte:");
Serial.print(addr_high, DEC);
Serial.print('\n');
Serial.print("Low Byte:");
Serial.print(addr_low, DEC);

and have the same result. I'm guessing that I'm getting incorrect results because the function is operating on the variables locally, despite them having being defined at the beginning of the program, I thought, as global variables.

Could someone show me what I should be doing or point me to a non-confusing tutorial please?

You should be posting all your code in code tags as explained here:
how to use the forum
because it is the only way we can see what your problem really is.

ProjectAVR:
I'm guessing that I'm getting incorrect results because the function is operating on the variables locally, despite them having being defined at the beginning of the program, I thought, as global variables.

What incorrect result are you getting?

I'm defining my variables before void setup()

When you post the whole program we will be able to see where and how you declare curr_addr and where it gets its value.

I'm getting incorrect results

Would you care to share the expected and unexpected results with us ?

Thanks guys, this is the current version of the program:

unsigned int curr_addr=3000;
unsigned int addr_low = 0,addr_high = 0;

void setup() {  
  Serial.begin(9600);  
}

void loop() {
  
  void addr_to_bytes();  
  Serial.print("Address:");  
  Serial.print(curr_addr, DEC);
  Serial.print('\n');
  Serial.print("High Byte:");
  Serial.print(addr_high, DEC);
  Serial.print('\n');
  Serial.print("Low Byte:");
  Serial.print(addr_low, DEC);
  
while(true){}
}

//Split address into two bytes
void addr_to_bytes()
{
  addr_low=curr_addr&0x00FF;
  addr_high=(curr_addr>>8)&0x00FF;
}

Expected results were:
Address:3000
High Byte:11
Low Byte:184

Actual results were:
Address:3000
High Byte:0
Low Byte:0

void loop() {
 
  void addr_to_bytes();

should be:

void loop() {
 
addr_to_bytes();

By the way, when you want to run something just once, you don't need to create a while(1) loop. Just put it in setup(), which runs once, and leave loop() empty.

Thank you aarg, as simple as that. Also, thanks for the pointer to put my code in tags.

ProjectAVR:
Thank you aarg, as simple as that. Also, thanks for the pointer to put my code in tags.

Do you understand why it works now and didn't work originally ?

I believe so UKHeliBob. The 'void' in front of my call was telling the compiler that it was a declaration rather than calling it as a function. Is that correct?

Is that correct?

I think that formally it is known as a function prototype (I am sure that someone will correct me if I am wrong) but it was certainly not calling the function.