C++ String reserve()Last Updated : 17 Mar 2025 This function requests a change in capacity. SyntaxConsider a string str and l is planned length of the string. Its syntax would be: Parameterl is the planned length for the string Note: capacity of the string can be greater than or equal to 'l'.Return valueIt does not return any value. ExampleLet's see the simple example. Output: Capacity is 27 Now,capacity is : 54 In this example, we observe that how capacity of the string varies using reserve() function. Next TopicC++ Strings |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India