Ad
  • Custom User Avatar

    you are using the C++ std::string, working with strings in c11 is a bit more painful since you can only have a null terminated char array
    https://www.tutorialspoint.com/cprogramming/c_strings.htm

    the example at the link above shows how to work with static char arrays but if you need a string of a dynamic length, of course the array can also be a dynamic one (obtained through malloc/calloc/realloc)

    you can no longer use str += 'x', instead use str[len++] = 'x'; str[len] = '\0';