Getting the first n elements of a specified char array

My aim is reading some string from serial for example 234124!3455addg#5867 if the program sees ! it should start to add it to a char array and if it sees # it should return the first 4 elements of that char array for my example the return should be 3455. How can I solve it? I made this using String class but I need to implement it to char array. I am quite new on arduino so please be clear thank you. Here is my code:

char Tmp[200];
bool b=0;
int counter;
void setup() {
    Serial.begin(9600);
    Serial.println("Enter a Message");
}
void loop() {
    while (Serial.available() > 0)
    {
      char recieved = Serial.read();
      
       if (recieved=='!' || b==1){
          if(b!=1){
            b=1;
            counter=0;
            }
          b=1;
          counter++;
          Tmp[counter]=Serial.read();
          delay(10);
          }
          
        else if (recieved=='#'){
        counter++;
        Tmp[counter]='\0';
        newPack(Tmp);
        return;
        }
        
   
    }}

dodgerbadger:
if the program sees ! it should start to add it to a char array

What is this 'it' you speak of?

dodgerbadger:
if it sees # it should return the first 4 elements of that char array for my example the return should be 3455.

Here's a list of libraries. One of them deals with character arrays, aka C-strings. You should be able to find something in there to accomplish this. You can find worked examples for many of them at https://www.cplusplus.com/reference/.