erasing a character from a string in c++
C++
// string::erase
#include <iostream>
#include <string>
int main ()
{
std::string str ("This is an example sentence.");
std::cout << str << '\n';
// "This is an example sentence."
str.erase (10,8); // ^^^^^^^^
std::cout << str << '\n';
// "This is an sentence."
str.erase (str.begin()+9); // ^
std::cout << str << '\n';
// "This is a sentence."
str.erase (str.begin()+5, str.end()-9); // ^^^^^
std::cout << str << '\n';
// "This sentence."
return 0;
}
Also in C++:
- Title
- hobo 8
- Category
- C++
- Title
- coping 2d vector in cpp
- Category
- C++
- Title
- insertion c++
- Category
- C++
- Title
- fmod c++
- Category
- C++
- Title
- loop through array c++
- Category
- C++
- Title
- c++ char define
- Category
- C++
- Title
- how to declare a function in c++
- Category
- C++
- Title
- how to grab all of user input c++
- Category
- C++
- Title
- preorder traversal c++
- Category
- C++
- Title
- removing repeated characters in a string c++
- Category
- C++
- Title
- shortest path with bfs in c++
- Category
- C++
- Title
- heap in cpp stl
- Category
- C++
- Title
- c++ std::copy to cout
- Category
- C++
- Title
- c++ initialize array
- Category
- C++
- Title
- pair in c++
- Category
- C++
- Title
- cpp loop through object
- Category
- C++
- Title
- append string to another string c++
- Category
- C++
- Title
- transpose matrix eigen c++
- Category
- C++
- Title
- array 2d to 1d
- Category
- C++
- Title
- first prime numbers
- Category
- C++
- Title
- c++ vector lower_bound index
- Category
- C++
- Title
- factorial in c++
- Category
- C++
- Title
- how to input multiple lines of a file in c++
- Category
- C++
- Title
- find_if c++ example
- Category
- C++
- Title
- c++ modulo make it give only positive numbers
- Category
- C++
- Title
- how to append an element to an array in cpp
- Category
- C++
- Title
- C++ sfinae
- Category
- C++
- Title
- linkedlist implementation in c++
- Category
- C++
- Title
- object slicing in c++
- Category
- C++
- Title
- c++ map insert
- Category
- C++
- Title
- to_string c++
- Category
- C++
- Title
- object reference not set to an instance of an object c#
- Category
- C++
- Title
- c++ function return pointer to itself
- Category
- C++
- Title
- max in c++
- Category
- C++
- Title
- c++ constructor
- Category
- C++
- Title
- sqrt cpp
- Category
- C++
- Title
- how to remove maximum number of characters in c++ cin,ignore
- Category
- C++
- Title
- how to output to console c++
- Category
- C++
- Title
- hohw toparse a string in c++
- Category
- C++
- Title
- c++ vector
- Category
- C++
- Title
- array sort c++
- Category
- C++
- Title
- call by reference c++ example
- Category
- C++
- Title
- c++ get type name of object
- Category
- C++
- Title
- pair c++
- Category
- C++
- Title
- c++ map find
- Category
- C++
- Title
- min heap priority queue c++
- Category
- C++
- Title
- sub string of vector c++
- Category
- C++
- Title
- iterate 2d array c++
- Category
- C++
- Title
- dynamic 2d array c++
- Category
- C++
- Title
- how to use wasd c++
- Category
- C++
- Title
- -> cpp
- Category
- C++
- Title
- how to make string get spaces c++
- Category
- C++
- Title
- howt o initialize 3d vector in c++
- Category
- C++
- Title
- c++ set add element
- Category
- C++
- Title
- pairs in c++
- Category
- C++
- Title
- new keyword in cpp
- Category
- C++
- Title
- c++ string to int
- Category
- C++
- Title
- pop_back
- Category
- C++
- Title
- goto c++
- Category
- C++
- Title
- log base 10 c+_+
- Category
- C++
- Title
- how to delete something in an array c++
- Category
- C++
- Title
- in c, is class uppercase or lowercase
- Category
- C++
- Title
- c++ transform
- Category
- C++
- Title
- static_cast c++
- Category
- C++
- Title
- c++ file to string
- Category
- C++
- Title
- what does count function do in hashmap
- Category
- C++
- Title
- gfg right view of tree
- Category
- C++
- Title
- cpp how to create an object of template class
- Category
- C++
- Title
- compare values within within a vector c++
- Category
- C++
- Title
- c++ menu selection with arrow keys
- Category
- C++
- Title
- including cpp header file in c++
- Category
- C++
- Title
- caesar cipher program in c++
- Category
- C++
- Title
- create copy of range of string c++
- Category
- C++
- Title
- sorting of array in c++
- Category
- C++
- Title
- c++ reverse vector
- Category
- C++
- Title
- how to run a c++ program in the background
- Category
- C++
- Title
- sfml basic program
- Category
- C++
- Title
- convert stirng to int c++
- Category
- C++
- Title
- queue stl c++
- Category
- C++
- Title
- two elements with difference K in c++
- Category
- C++
- Title
- what is difffrence between s.length() and s.size()
- Category
- C++
- Title
- checking an int in c++
- Category
- C++
- Title
- how to find the mode of a vector c++
- Category
- C++
- Title
- c++ read matttrix from text file
- Category
- C++
- Title
- rgb(100,100,100,0.5) validation c++
- Category
- C++
- Title
- modulo c++
- Category
- C++
- Title
- how to find the index of an element in a vector c++
- Category
- C++
- Title
- first fit algorithm
- Category
- C++
- Title
- std::substring
- Category
- C++
- Title
- statement that causes a function to end in c++
- Category
- C++
- Title
- C++ Syntax
- Category
- C++
- Title
- declaring vector c++
- Category
- C++
- Title
- array<string, 7> c++
- Category
- C++
- Title
- how to iterate through a map in c++
- Category
- C++
- Title
- ue4 c++ struct
- Category
- C++
- Title
- pass vector by reference c++
- Category
- C++
- Title
- c++ give options string
- Category
- C++
- Title
- how to avoid tle in c++
- Category
- C++
- Title
- c++ evaluate expression
- Category
- C++
- Title
- set c++
- Category
- C++