Ad
  • Default User Avatar

    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).

  • Custom User Avatar

    Well it is a 7...

    How did you do this in constant time? That doesn't seem possible.

  • Custom User Avatar

    Great! for future reference this shouldn't be marked as an "issue" but as a "question".

  • Custom User Avatar

    Edit: problem solved

  • Custom User Avatar
  • Custom User Avatar

    This was harder than I thought it would be...

  • Custom User Avatar

    Maybe a bit the other way round: calloc is something like a combo of malloc and memset to 0.

    Since your question seems to be answered, let me mark it as resolved.

  • Custom User Avatar

    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!

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Worked fine on my end. Are you filtering by len()?

  • Loading more items...