reverses a null terminated string