Search
 
SCRIPT & CODE EXAMPLE
 

CPP

removing a character from a string in c++

#include<iostream>
#include<algorithm>

using namespace std;
main() {
   string my_str = "ABAABACCABA";

   cout << "Initial string: " << my_str << endl;

   my_str.erase(remove(my_str.begin(), my_str.end(), 'A'), my_str.end()); //remove A from string
   cout << "Final string: " << my_str;
}
Comment

how we can write code to remove a character in c++

nclude<iostream>
#include<algorithm>

using namespace std;
main() {
   string my_str = "ABAABACCABA";

   cout << "Initial string: " << my_str << endl;

   my_str.erase(remove(my_str.begin(), my_str.end(), 'A'), my_str.end()); //remove A from string
   cout << "Final string: " << my_str;
Comment

PREVIOUS NEXT
Code Example
Cpp :: if in c++ 
Cpp :: Basic Makefile C++ 
Cpp :: c++ switch case 
Cpp :: Valid Parentheses leetcode in c++ 
Cpp :: phi function (n log (log(n))) 
Cpp :: build a prefix array cpp 
Cpp :: C++ Pointers to Structure 
Cpp :: c++ unordered_map initialize new value 
Cpp :: even and odd numbers 1 to 100 
Cpp :: bubble sort function in c++ 
Cpp :: floyd algorithm 
Cpp :: 83. remove duplicates from sorted list solution in c++ 
Cpp :: how to show constellations in starry night orion special edition 
Cpp :: lcm in c++ 
Cpp :: flipperRSocketResponder.cpp command failed react native 
Cpp :: Maximum Weight Difference codechef solution c++ 
Cpp :: i++ i-- 
Cpp :: idnefier endl in undefince 
Cpp :: Corong_ExerciseNo3 
Cpp :: cpp how to add collisions to boxes 
Cpp :: get range sum 
Cpp :: static member fn , instance 
Cpp :: c plus 
Cpp :: remove digit from number c++ 
Cpp :: how to draw a rectangle with diagonals and axes of symmetry in c ++ in the console? 
Cpp :: what does npl mean? 
Cpp :: hamming c++ 
Cpp :: time function in c++ 
Cpp :: std remove example 
Cpp :: how to get a section of a string in c++ 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =