The struct maybe_double is a way to return both conversion status and result at the same time. The field value_exists means that the input string was successfully parsed. If it is true, then the conversion succeeded and the result is inside the field value. If it is false, then the input string was not a representation of a float (and the field value is ignored).
A week or two ago I struggled on this one. Spent a few hours trying to figure it out. Did a different problem that "clicked" differently and then it gave me an idea for this one...and 10 mins later it's done. Ahhhh.....
I don't see what you'd mean by "buffer has to be cleared", it does not have to, solution just has to properly null-terminate it
Well, I thought the buffer would be ready for me to copy the string without needing to null-terminate it myself, so I had "fun" time figuring out what's wrong. It was my mistake to assume this, and this is probably more of a suggestion than an issue, but it'd still be good if the author was clear about his intentions considering how important correct memory management is.
Your solution does not put null terminator in the output buffer. Upon a call to your function, output buffer is allowed to have any content, it's responsibility of your solution to null terminate it properly.
Is this still an issue? I don't see what you'd mean by "buffer has to be cleared", it does not have to, solution just has to properly null-terminate it. Was the issue raised by you fixed? Or am I missing something?
The struct
maybe_double
is a way to return both conversion status and result at the same time. The fieldvalue_exists
means that the input string was successfully parsed. If it istrue
, then the conversion succeeded and the result is inside the fieldvalue
. If it isfalse
, then the input string was not a representation of a float (and the fieldvalue
is ignored).Well it is a 7...
How did you do this in constant time? That doesn't seem possible.
Great! for future reference this shouldn't be marked as an "issue" but as a "question".
Edit: problem solved
This was harder than I thought it would be...
Maybe a bit the other way round:
calloc
is something like a combo ofmalloc
andmemset
to 0.Since your question seems to be answered, let me mark it as resolved.
A week or two ago I struggled on this one. Spent a few hours trying to figure it out. Did a different problem that "clicked" differently and then it gave me an idea for this one...and 10 mins later it's done. Ahhhh.....
Thank you to the author this was a good one!
This comment is hidden because it contains spoiler information about the solution
Well, I thought the buffer would be ready for me to copy the string without needing to null-terminate it myself, so I had "fun" time figuring out what's wrong. It was my mistake to assume this, and this is probably more of a suggestion than an issue, but it'd still be good if the author was clear about his intentions considering how important correct memory management is.
Your solution does not put null terminator in the output buffer. Upon a call to your function, output buffer is allowed to have any content, it's responsibility of your solution to null terminate it properly.
Is this still an issue? I don't see what you'd mean by "buffer has to be cleared", it does not have to, solution just has to properly null-terminate it. Was the issue raised by you fixed? Or am I missing something?
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Worked fine on my end. Are you filtering by len()?
Loading more items...