Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Hello.
Just why edi ok with test, but not when attempt ?
Forgot to remove debug strings ^^ and also printf debug ^^
Yes, indeed
Runtime per se won't be a problem here (maybe it is about 0.4ms). The real trouble is, that this ends up in an infinite loop for values above the square closest to INT_MAX.
Nice !
But what about big numbers, according compute time (eg: 2147395600 or 2147483647)
Hello siebenschlaefer,
is using
a locally allocated char array
which is returned via strdup(charray)
a form of memory leak?
thank you,
rowcased
This comment is hidden because it contains spoiler information about the solution
Hello.
Mybe i already saw that somewhere many many time ago, but i prefer tell i didn't know that function.
In my first answer, i made the wheel again, almost ^^.
Thanks to have been learnt me that function.
This comment is hidden because it contains spoiler information about the solution
char *variablename[size];
definesvariablename
to be an array ofchar *
, not ofchar
.list
, so any fixed sizethestring
might be too small.MIN_INT
is-2147483648
, sodummystr
should be able to take 16 characters (11 for theint
, 4 for" -> "
and 1 for the terminating'\0'
).thestring
has automatic storage duration (i.e. resides on the stack), its lifetime ends when the execution ofstringify
ends.return thestring
returns a pointer to that array, resulting in undefined behaviour.Yes, this function allocates some memory and the caller is reposible for deallocation. That's common in C programs.
All alternatives either leak memory, cannot handle arbitrarily large results, and/or are not thread safe or reentrant.
Hello.
What about the memory.
malloc allocated memory, but never released, isn't it ?
Hello all.
My, i didn't think about ... THAT !!!
Of course !!!
Thank you very much for this hint !!! I should read more carrefully next time !!!