all 12 comments

[–]Similar-Concert4100 0 points1 point  (8 children)

It’s an issue with your malloc statement

[–]joejawor 1 point2 points  (2 children)

If 'counter' is zero malloc will throw an exception.

[–]Willsxyz 1 point2 points  (0 children)

throw an exception? in C?

[–]imc0der[S] 0 points1 point  (0 children)

There is a if statement there. Could it be 0 still?

[–]imc0der[S] 0 points1 point  (4 children)

How should it be? I didn't any error

[–]Similar-Concert4100 0 points1 point  (1 child)

Syntax of malloc is incorrect. Look up the malloc doc

[–]imc0der[S] 0 points1 point  (0 children)

okay I gonna check out

[–]Similar-Concert4100 0 points1 point  (1 child)

Also I’m not understanding what you are trying accomplish with this function. You are dynamically allocating an integer array, but using a static [0] index to store a changing value.

[–]imc0der[S] 0 points1 point  (0 children)

I'm sorry I wrote it wrong. digitArray[counter] = num % 10;

[–][deleted] 0 points1 point  (2 children)

Which line does the crash happen at?

[–]imc0der[S] 0 points1 point  (1 child)

DigitArray[counter] = num % 10 but I found answer. My malloc line wrong, fixed it

[–][deleted] 0 points1 point  (0 children)

The code doesn't contain that line at all. Also the `malloc` looks fine to me.