Problems on serial.read()

I was wrong about return local objects. The problem of 'undefined behavior' only happens if you are return references to a local object. A local object is always destroyed at the end of function/method. But, in your case, you are return a object by value. So, the C++ will make a safe copy before destroy it.

Are you corrected the 'for' loop too?

I think must be like this to get the 'salto' value from string:

for (c = i = 0; c < 3; c++) {