Question using StackArray Library with serial

I’m trying to understand what is happening in my code. It May be that I am miss understanding how the Serial input is working along side of my stack. The code is suppose to check if a serial is available, then stack all the characters from the serial. Then it is suppose to loop back through and print all the letters displayed on the same line. I understand that this will print in reverse, the problem I am having is that it prints the first letter of the string, then the rest in reverse. It seems to only stack one letter, print it, then stack the rest and print it.

Here is my code:

void setup() {

void loop() {

if(Serial.available() > 0){
StackArray stack;

while (Serial.available() > 0){

Serial.println("Recieved Info: ");
Serial.print("Serial Available Number is : ");
Serial.print("The Message Recieved is : ");

while (!stack.isEmpty()){


I a little programming background, just haven’t dealt much with serial. If someone could clear this up for me, that would be great, thanks.

That cannot be the full code because there is no reference to the library you are using. Also post a link to the source of the library code.

I think the examples in Serial Input Basics will do what you are trying to achieve without the need for any external library.

while (Serial.available() > 0)
is not a reliable way to receive a complete message because Serial data arrives very slowly compared to an Arduino.