Skip to content

Instantly share code, notes, and snippets.

@Akira-Hayasaka
Last active June 1, 2022 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akira-Hayasaka/074a00ce98cf92eeb78f9d7eb57caed2 to your computer and use it in GitHub Desktop.
Save Akira-Hayasaka/074a00ce98cf92eeb78f9d7eb57caed2 to your computer and use it in GitHub Desktop.
prepend zero
static string prepend_0(const int i, const int n_zero)
{
return std::string(n_zero - std::min(n_zero, (int)ofToString(i).length()), '0') + ofToString(i);
}
auto prepend_0 = [&](const int i, const int n_zero) -> string
{
return std::string(n_zero - std::min(n_zero, (int)ofToString(i).length()), '0') + ofToString(i);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment