That was just because you copied the small string in. If you instead first push back, then getttyname, then push/pop back 0 it should be fine.