How to make an array buffer global

I am having a problem printing out an array which was loaded with AAA, ie 65 65 65, at run time and then I change it to BBB, ie 66, 66, 66, after a pushbutton is pressed.

It keeps printing out the 65, 65, 65 and ignoring what I have changed it to.

Is this a global issue?

uint8_t buff[] = "AAA";      //load buffer with AAA
const int buttonPin1 = 0;     //the number of the pushbutton pin
int buttonState1 = 0;        //variable for reading the pushbutton status


void setup()
{
  pinMode(buttonPin1, INPUT_PULLUP);//initialize the pushbutton pin as an input
}


void loop()
{
  buttonState1 = digitalRead(buttonPin1);   // check if the pushbutton is pressed. If it is, the buttonState is LOW: 

  delay(200);             //slow down to avoid repeated button reads

  if (buttonState1 == LOW) {    
    Serial.println("button1 pressed");  //acknowledge button pressed
    uint8_t buff[] = "BBB";                   //change the buffer to BBB
    myPnt();                                     //send to serial print   
    }
}


void myPnt()
{
  for (int x = 0; x < 3; x++)
  {
     Serial.println(buff[x]);    //out to serial print
  }
}

By using a type identifier (uint8_t in this case), you are declaring a new variable.

Spare the type definition and buff will refer to the global buff defined earlier.

I removed the type definition from the line after Serial.println and now I get an error.

if (buttonState1 == LOW) {    
    Serial.println("button1 pressed");
    buff[]= "BBB";   //change the buffer to 1234
    myPnt();               
    }

Error points at buff[]

Compilation error: expected primary-expression before ']' token

uint8_t buff[] = "AAA"; //load buffer with AAA

Because you used the double quotation marks around AAA, you have actually declared a 4 byte character array terminated by '\0'.

You can use that to fill the array with strcpy.

strcpy(buff,"BBB");

Alternatively, you can fill the array much like you print it out.

for (int x = 0; x < 3; x++)
  {
     buff[x] = 'B';    //fill buff with 'B'
  }

Thanks cattledog,

The strcpy function brought up an error:

Compilation error: invalid conversion from 'uint8_t* {aka unsigned char*}' to 'char*' [-fpermissive]

however your alternative "for"code did work OK..

Thanks

Usually chars are stored in a char buffer[].
So change uint8_t to char.
Or maye change uint8_t to int8_t.
Or cast your character to a uint8_t inside the for loop.
(uint8_t) 'b'