Hot answers tagged

8 votes

Thread-safe strtok in C

Since this is not a drop-in replacement of strtok, which iterates token, but only allows a complete tokenization of a string, I'd not expose ...
vnp's user avatar
  • 56.3k
6 votes

Thread-safe strtok in C

You don't need the inclusion of stdlib.h in com_github_coderodde_thread_safe_strtok.h. For the definition of ...
Harith's user avatar
  • 4,021
6 votes

Thread-safe strtok in C

Significant semantic differences from strtok() I decided to practice and write a thread-safe version of the same function. Yours is not "a thread-safe ...
John Bollinger's user avatar
4 votes

Thread-safe strtok in C - version II

Reconsider token_t This is currently a linear linked list of tokens, surprising given the name. A strictly-evaluated linear linked list isn’t an efficient data ...
Davislor's user avatar
  • 6,706
4 votes
Accepted

Fast search for the longest repeating substrings in large text (Rev.4)

Answers to your questions One concern is replacing size_t with auto for size(). Won’t size_t...
G. Sliepen's user avatar
  • 54.1k
2 votes
Accepted

Fast search for the longest repeating substrings in large text (Rev.3)

Don't use decltype() unnecessarily In Index you have this member functions: ...
G. Sliepen's user avatar
  • 54.1k
2 votes

Error handling with C-string input using get() and getline()

Writing all the code in a single huge main() is not only hard to read, but also a poor use of your skills. Write a re-usable function to prompt and read input from ...
Toby Speight's user avatar
  • 74.4k
2 votes

Truncating/abbreviating strings in the middle with an ellipsis (…) (or other) separators with a fixed character limit

Thanks to Peter Csala for providing you an example on how to convert your code into using Span<T>, and I think his answer covered that. I just want to add ...
iSR5's user avatar
  • 5,208
2 votes
Accepted

Truncating/abbreviating strings in the middle with an ellipsis (…) (or other) separators with a fixed character limit

Let me present you an alternative version of your TruncateInMiddle which utilizes ReadOnlySpans. The core logic can be rewritten ...
Peter Csala's user avatar
  • 8,820

Only top scored, non community-wiki answers of a minimum length are eligible