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)
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.
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?
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 timeyour allocation of
5
bytes forcStr
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)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.
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?
Have you tried printing the input?
Not an issue. Your solution is wrong.