pop_back(): This function removes the last character from the given string.
Note: The string must be non-empty for this function.
Parameter: No parameters are required for this function.
Syntax:
str.pop_back()
For Example:
str = "abc"
str.pop_back() => It removes last character (i.e 'c') from string and string becomes "ab".
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){string str = "abc";str.pop_back();cout << str << "\n";return 0;}
No comments:
Post a Comment