Skip to main content
Share Your Experience: Take the 2024 Developer Survey

New answers tagged

1 vote

C++ program to format byte sequences into Python like string representations

We're missing an include of <cstring> (required for std::memcpy). Most C++ programmers prefer ...
Toby Speight's user avatar
3 votes

locale-aware trim functions for std::string

It's surprising that std::string defaults to "C" locale, but all other string types default to using the global locale. That's likely to cause user ...
Toby Speight's user avatar
0 votes

Convert string to mixed case

Here's a way of doing it with streams ...
user283226's user avatar
4 votes

Implementing strscpy(): Is using errno as a negative return value a bad practice?

Opinion: argument order ssize_t ft_strscpy(char *dst, const char *src, size_t size), even though it matches sized_strscpy(), ...
7 votes

Implementing strscpy(): Is using errno as a negative return value a bad practice?

Use C99's new meaning of static keyword: If we shift around the parameters, we can have: ...
Harith's user avatar
  • 6,992
2 votes

Implementing basename, stpcpy, asprintf, vasprintf, strchrnul, and strcasecmp

Whilst util_stpcpy() isn't wrong, it's possibly less efficient than a implementation tuned for the target architecture, which can fold finding the end into an ...
Toby Speight's user avatar
3 votes

Implementing basename, stpcpy, asprintf, vasprintf, strchrnul, and strcasecmp

Bug: questionable compare. Code does if (islower((unsigned char) p)) { p = toupper((unsigned char) p); } yet documentation has In the ...
chux - Reinstate Monica's user avatar
3 votes

Implementing basename, stpcpy, asprintf, vasprintf, strchrnul, and strcasecmp

Potential idea C2x is planned to support QChar *strchr(QChar *s, int c); This QChar allows one to call ...
5 votes
Accepted

Implementing basename, stpcpy, asprintf, vasprintf, strchrnul, and strcasecmp

bump the pointer ...
J_H's user avatar
  • 27.6k
2 votes
Accepted

Advanced String Calculator with asin, acos, atan Functions in C++

It is inefficient Your code is very inefficient for various reasons. First, StringCalculator itself only handles braces. It finds the innermost braces, then uses <...
G. Sliepen's user avatar
  • 57.2k
4 votes

Leetcode - First Unique Character in a String

Pay attention to Constraints While cracking algorithmic problems, pay very close attention to the constraints of the problem at hand. They can often give valuable clues on how to attack the problem. ...
Alexander Ivanchenko's user avatar
-2 votes

Leetcode - First Unique Character in a String

In Java Use the FirstIndexOf() and LastIndexOf() if these both return the same number then its the unique character in the statring of the string return the index of it break the loop. This is the ...
Ajay Shankar's user avatar
4 votes

is_number Function Implementation in C++

isdigit() expects an int that can be represented as an unsigned char or ...
Harith's user avatar
  • 6,992
7 votes
Accepted

is_number Function Implementation in C++

You can make it constexpr You can make both functions constexpr, ensuring you can do compile-time checking of strings for valid ...
G. Sliepen's user avatar
  • 57.2k
1 vote

Generating sequential alphanumeric values that match a certain pattern

Many of the examples include the 'Z' character, but the CMS medicare spec specifically states to not use the Z character for readability (looks like a 2). So the reg exp and other samples run but ...
STEVEN BENDER's user avatar
4 votes
Accepted

String character changes (case insensitive) - Go

A few comments. Simple is good. strchange.go: ...
peterSO's user avatar
  • 3,521

Top 50 recent answers are included