[Solved] Easy C++ = array length and reverse WITHOUT


Consider for (int i = 0; i < *length; i++) where both i and *length are 0, as in your case… will that loop ever execute? Nope… Consider a loop that starts with x set to 0 and return x; when str[x] is '\0'. i.e. the loop in strlen does this.

As for printing backwards, start at the highest index (returned by strlen or your function once fixed) and decrement until you reach 0, printing the characters at those offsets as you go.

strlen is available in <cstring>, by the way, not just <string>… and as it is a mandatory function it’ll always be part of any C++ implementation. You should probably just use strlen

solved Easy C++ = array length and reverse WITHOUT