Arduino programming question about array

How can i do this? Thanks for help :sob:

Extend the program to read an integer (with at most 2 digits) from the Serial Monitor and print out a group of stars that is equal to the integer value. The star should be arranged in rows of ten.

The result example:

This is a test
incorrect input

5234
incorrect input

20



0

8


char buf[100] = {0};  // this is an array
char inChar;

bool stringComplete = false;

int i = 0;



// declare the function

char ConvertString(char);



void setup()

{

  // Initialize serial and wait for port to open

  Serial.begin(115200);

  while (!Serial)

  {

    // Wait for serial port to connect, needed for native USB port only

  }

}



void loop()

{

  while (Serial.available())

  {

    inChar = (char)Serial.read();



    if (inChar == '\n')   // change '\n' to '~' when using Tinkercad

    {

      buf[i++] = inChar;  // last character is newline

      buf[i] = 0;         // string array should be terminated with a zero

      stringComplete = true;

    }

    else

    {

      

      buf[i++] = inChar;

    }

  }



  if (stringComplete)

  {

    Serial.print(buf);    // the printing of string will be stopped when zero is reached

    stringComplete = false;

    i = 0;

  }

}


char buf[100];
int  i = 0;

// -------------------------------------
void setup()
{
    Serial.begin(115200);
}

// -------------------------------------
void
pr (
    char *buf)
{
    int val = atoi (buf);
    Serial.println (val);

    if (100 <= val)
        return;

    for (int n = 0; n < val; n++)  {
        if (0 < n && (! (n % 10)))
            Serial.println ("");
        Serial.print ("*");
    }
    Serial.println ("");
}

// -------------------------------------
void loop()
{
    while (Serial.available())
    {
        buf [i++] = (char)Serial.read();

        if ('\n' == buf[i-1])  {
            pr (buf);
            i = 0;
        }
    }
}

Send the number with '\n' terminated character, and then: