MCPcopy Create free account
hub / github.com/fmtlib/fmt / increment

Function increment

test/format-test.cc:174–182  ·  view source on GitHub ↗

Increment a number in a string.

Source from the content-addressed store, hash-verified

172
173// Increment a number in a string.
174void increment(char* s) {
175 for (int i = static_cast<int>(std::strlen(s)) - 1; i >= 0; --i) {
176 if (s[i] != '9') {
177 ++s[i];
178 break;
179 }
180 s[i] = '0';
181 }
182}
183
184TEST(util_test, increment) {
185 char s[10] = "123";

Callers 1

TESTFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected