Help with arduino coding!!

i need some help with codes please!!

how do i fix this?

  char input [ 10 ];
  int index;
  
  // clears string
  for ( index = 0; index < 10; ++index )
  input[index] = '\0'; 
  
  // incoming data equals to string
  for ( index = 0; Serial.available() > 0; ++index )
  {input[index] = Serial.read();}

  char msg[ 11 ];
  //print string
  sprintf (msg, "%s Messages...",input );

Senario:

lets say that i kept sending value of “92” to arduino the every 5 sec.

and the rate of it arduino printing the message is every 15 second

on the second loop onwards what i get is “929292 message”

the problem is the rate of sending is impair to the rate of printing,
which is why im getting three “92” appearing on the message.

i know i can set it both to equal rate to avoid this problem. but is there any other way to adress this problem?

bitwise & it??i think im too stupid to change the code here :’(

also…please pardon my poor english

i have a python script taking care of the data transmitting task

so how do i end the transmission?

  char msg[ 11 ];
  //print string
  sprintf (msg, "%s Messages...",input );

The up-to-10 values from input, the string " Messages", and a terminating NULL will not fit in an 11 element array.

Serial communication is asynchronous. You can not make any assumptions on the amount of data to be received, when the data will be received ("i kept sending value of "92" to arduino the every 5 sec."), or when the data will be sent ("and the rate of it arduino printing the message is every 15 second").

but is there any other way to adress this problem?

You need to understand the nature of serial communication to see why what is happening is to be expected.

It is not clear to me why what is happening is a problem, or how you want to deal with it.