Use remove_copy with vector : remove_copy « STL Algorithms Modifying sequence operations « C++ Tutorial






#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
   
int main()
{
  char str[] = "This is a test.";
  vector<char> v, v2(30);
  unsigned int i;
   
  for(i=0; str[i]; i++) v.push_back(str[i]);
   
  for(i=0; i<v.size(); i++) {
     cout << v[i] << endl;
  }
  
  remove_copy(v.begin(), v.end(), v2.begin(), ' ');
   
  for(i=0; i<v2.size(); i++) cout << v2[i];
  cout << endl << endl;
  
  return 0;
}








24.9.remove_copy
24.9.1.std::remove_copy
24.9.2.Use remove_copy to delete all space in a char array
24.9.3.Use remove_copy with vector
24.9.4.Use remove_copy to print elements without those having the value 3
24.9.5.Copy from one vector to another and remove values with remove_copy()