Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

std remove example

// remove algorithm example
#include <iostream>     // std::cout
#include <algorithm>    // std::remove

int main () {
  int myints[] = {10,20,30,30,20,10,10,20};      // 10 20 30 30 20 10 10 20

  // bounds of range:
  int* pbegin = myints;                          // ^
  int* pend = myints+sizeof(myints)/sizeof(int); // ^                       ^

  pend = std::remove (pbegin, pend, 20);         // 10 30 30 10 10 ?  ?  ?
                                                 // ^              ^
  std::cout << "range contains:";
  for (int* p=pbegin; p!=pend; ++p)
    std::cout << ' ' << *p;
  std::cout << '
';

  return 0;
}
Source by cplusplus.com #
 
PREVIOUS NEXT
Tagged: #std #remove
ADD COMMENT
Topic
Name
6+3 =