void clear() - JanKulbaga/String-CPP GitHub Wiki

void clear()

Erases the contents of the string, which becomes an empty string (with a length of 0 and data nullptr).

Example

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

int main()
{
    String s = "Hello World";
    s.clear()
    std::cout << s.length() << "\n";
    std::cout << s.isEmpty() << "\n";
    return 0;
}

Output:

0
1

Parameters

None

Return type

None

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