Ad
  • Default User Avatar
    int cur, idx, amount = 0;
    

    idx is not initialized, meaning its value when the function is entered is arbitrary, and will sometimes cause out-of-bounds accesses, depending on what's on the stack at this point in time

    your allocation of 5 bytes for cStr is also rather optimistic, what if your function is called with "0123456.789.10.11 ? (i dont know if such inputs are tested since the kata is underspecified, but in C you should always be careful)

  • Custom User Avatar

    So try reinitializing this pointer on each function call, or something like that (sorry if this is not correct or not correctly worded, but as I said I didn't scrutinize your code and don't know what it is doing).

    You can do the trial yourself: in the test window (at the bottom page): your code passes all tests taken one by one; by it crashes as soon as there are two or more consecutive tests.

  • Custom User Avatar

    What's weird is when one runs your code test after test, here too it works fine. But when running several tests on a row then the code crashes. I didn't examine your code in detail. Don't you have something like a global variable somewhere?

  • Custom User Avatar

    Have you tried printing the input?

  • Custom User Avatar

    Not an issue. Your solution is wrong.