Home » C++ String clear() function

C++ String clear() function

by Online Tutorials Library

C++ String clear()

This function removes the elements, becomes an empty string.

Syntax

Consider a string str. Syntax would be:

Parameter

This function does not contain any parameter.

Return value

This function does not return any value.

Example

Let’s see a simple example of clear() function:

Output:

Enter some lines about TutorAspire and write dot character to finish the sentence  If you want to clear the text, press d  

This example shows how clear() function works.

Next TopicC++ Strings

You may also like