This is a C++ program that demonstrates the use of the resize method in the std::string class. The resize method is used to change the size of a string to a specified length, either by truncating the string or by adding additional characters. The program works as follows:
Overall, this program demonstrates how to use the resize method to change the size of a string in C++, either by truncating the string or by adding additional characters.
#include<iostream> #include<string.h> using namespace std; int main() { string str = "TutorJoe's is a Coaching centre"; cout<<"\nThe Initial string is : "; cout<<str<<endl; str.resize(10); cout<<"\nThe string after resize is : "; cout<<str<<endl; return 0; }To download raw file Click Here
The Initial string is : TutorJoe's is a Coaching centre The string after resize is : TutorJoe's
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions