Ad
  • Default User Avatar

    char result[100000] = {0}; -- you create local array. And return pointer to it: return result;. But after you leave the function factors() pointer becomes invalid. Therefore, undefined behavior here.