C++ String resize()Last Updated : 17 Mar 2025 This function is used to resize the string to the length of k characters. SyntaxConsider a string object str. To resize the string object, syntax would be : ParametersThis function contains two parameters.
If k is shorter than the length of the string, string length shortened to the length specified by k, removing all the characters beyond k. If k is larger than the length of the string, string length extended to the length specified by k. Return valueIt does not return any value. Example 1When k is shorter than length of the specified string. Example 2When k is greater than the length of the specified string. Output: String value is javatpoint After resizing, string value is javatpoint tutorial 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