Join space e char with integer in code

People, I'm back with a P10 panel and an arduino uno. When a single counter reaches 0, I display a STOP message that scrolls across the panel. But I would like to show STOP + int x which is equal to 10. So it will scroll like this on the panel:

STOP 10

Then if x is 11:

STOP 11

How should this code snippet look to do this ?

int x = 10;
if(counter == 0) {
      const char *next = "    STOP     ";
     while(*next) {
      box1.print(*next);
      next++;
      delay(120);
      }
    }

not sure what why you do next++ when next is a char array

what about

    int x = 10;
    char next [40];
    if(counter == 0) {
        sprintf (next, "    STOP %d", x);

For informed help, please read and follow the directions in the "How to get the best out of this forum" post.

Is better not to use the message as const and avoid pointers. Use index of char instead.

int x = 10;
char msg[50];   // Set enough length to avoid buffer overflow  
sprintf(msg ," STOP %d  ", x);

  if (counter == 0) {
      for (int n = 0; n < strlen(msg); n++) {
          box1.print(msg[n]);
          delay(120)
      }
  }

Just one more tip, is good practise to not create variables inside "if" and others conditionals.

I disagree. Variables should only be visible where needed.

Well this is a simple snipper, but with codes with many lines, if you end up adding an else stament for a new feature/improvement and "maybe" you need this variable, is a waste of time.

Unless you like to duplicate the declaration.

If I need a different scope, I would move the declaration.