The reason is that L
is the length of the array and you do this:
c = L;
because of 0 indexing you are starting past the end of the string. Try this:
c = L-1;
Of course since this is c++, I am going to tell you the standard thing which is don't use arrays! your code could be this:
std::string SlowText(std::string s)
{
for (auto b = s.rend(), e = s.rbegin(); b != e; b++)
{
std::cout << *b << std::flush;
sleep(250)
}
return ""; //Also why have this?
}