String zfill() - JanKulbaga/String-CPP GitHub Wiki

String zfill()

Returns a new string with 0 characters padded to the left side of the given string.

Example

#include <ostream>
#include "src/String.h"

int main()
{
    String s = "Hello";
    std::cout << s.zfill(10) << "\n";
    std::cout << s.zfill(5) << "\n";
    return 0;
}

Output:

00000Hello
Hello

Parameters

size_t num

Return value

Returns a new string with 0 filled to the left.

⚠️ **GitHub.com Fallback** ⚠️