Use generic deque to store chars : deque « Deque « C++






Use generic deque to store chars

  
 

#include <iostream>
#include <cassert>
#include <deque>
#include <algorithm>  // For find
using namespace std;


int main()
{
  char x[5] = {'a', 'r', 'e', 'q', 't'};

  deque<char> deque1(&x[0], &x[5]);

  // Search for the first occurrence of the letter e:
  deque<char>::iterator where = find(deque1.begin(), deque1.end(), 'e');

  assert (*where == 'e' );
  cout << "Ok." << endl;
  return 0;
}
/* 
Ok.

 */
        
    
  








Related examples in the same category

1.Use generic deque to store integers
2.Use generic deque to store strings
3.Initialize deque with 26 copies of the letter x
4.create a deque
5.Use std::copy to print out all elements in a deque
6.deque.push_back( value )
7.deque.push_front( value )
8.Create your own stack based on deque
9.Combine insert and end to add elements to a deque
10.Save transformed data from vector to deque (Vector1 + Vector2 = Result (in Deque))