how to create buffer for elapsed time ??

i want to to store elapsed time value into buffer and when communication is complete then measure it...

unsigned int CurrentTime = micros();
sketch 
unsigned int CurrentTime = micros();
 
   unsigned int ElapsedTime = CurrentTime - StartTime;
  
Serial.print("ElapsedTime");
Serial.println(ElapsedTime);

can any one help how to do it

Good start, but always use unsigned long for variables associate with millis() or micros().

Study the "blink without delay" example that comes with the Arduino IDE.

how can i store the elapsed time to buffer or array and after 20 or 50 iteration of communication print it on serial monitor

how can i store the elapsed time to buffer or array

Elapsed time is a concept. The value returned by millis() or micros() is a scalar value.

You store scalar values in arrays the same way, regardless of what the scalar value is.

The real question is why do you want to store an array of elapsed times? How many elapsed times? When do you want to deal with the array? How?

i want to store it b/c i want print elapsed time after 50 iteration of loop is run ....if i print elapsed time after every iteration the communication time increase i want that communication is done for 50 iteration then print the elapsed time

ishtiaq:
i want to store it b/c i want print elapsed time after 50 iteration of loop is run ....if i print elapsed time after every iteration the communication time increase i want that communication is done for 50 iteration then print the elapsed time

Do you want to know the time it takes to execute some block of code 50 times, or do you want to know all 50 times that it takes to execute the block of code once?

Printing the time that it takes to execute a block of code does not affect how long it takes to execute the block of code. It does affect how long it takes to execute the block of code again.

The bottom line: What problem are you trying to solve?

i want to know all 50 times each when communication is done for 50 iteration

ishtiaq:
i want to to store elapsed time value into buffer and when communication is complete then measure it...

unsigned int CurrentTime = micros();

sketch
unsigned int CurrentTime = micros();

unsigned int ElapsedTime = CurrentTime - StartTime;
 
Serial.print("ElapsedTime");
Serial.println(ElapsedTime);



can any one help how to do it

Just create an array for the times:

unsigned long capturedTime[50];

Using the array is very basic programming, no need to explain that here. Look up "array indexing".