Use generic vector to create vector of chars : vector « vector « C++ Tutorial

Home
C++ Tutorial
1.Language Basics
2.Data Types
3.Operators statements
4.Array
5.Development
6.Exceptions
7.Function
8.Structure
9.Class
10.Operator Overloading
11.Pointer
12.File Stream
13.template
14.STL Introduction
15.string
16.vector
17.list
18.bitset
19.set multiset
20.valarray
21.queue stack
22.deque
23.map multimap
24.STL Algorithms Modifying sequence operations
25.STL Algorithms Non modifying sequence operations
26.STL Algorithms Binary search
27.STL Algorithms Sorting
28.STL Algorithms Merge
29.STL Algorithms Min Max
30.STL Algorithms Iterator
31.STL Algorithms Heap
32.STL Algorithms Helper
C / ANSI-C
C Tutorial
C++
Visual C++ .NET
C++ Tutorial » vector » vector 
16.1.3.Use generic vector to create vector of chars
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>  // For find
using namespace std;


int main()
{
  char x[5{'a''b''c''d''f'};

  vector<char> vector1(&x[0], &x[5]);

  // Search for the first occurrence
  vector<char>::iterator where = find(vector1.begin(), vector1.end()'b');


  cout << *where  << endl;
  return 0;
}
b
16.1.vector
16.1.1.Demonstrating the simplest STL vector constructors: duplicate chars
16.1.2.Demonstrating the simplest STL vector constructors: empty vector
16.1.3.Use generic vector to create vector of chars
16.1.4.Use generic vector to create vector of integers
16.1.5.creates a vector of ints with zero elements
16.1.6.creates a vector of 10 ints with value 100
16.1.7.Use generic vector to create vector of strings
16.1.8.The Instantiation of vector
16.1.9.Using the vector
16.1.10.get an iterator that points to the maximum with max_element
16.1.11.Assign elements in int array to vector
16.1.12.Store a class object in a vector
16.1.13.Read keyboard input to a vector
16.1.14.Add class to a vector and then delete them one by one
16.1.15.Pass vector to a function
16.1.16.Computing an inner product of tuples represented as vectors
16.1.17.Assign value to the last element
16.1.18.Demonstrating STL vector copying constructors
16.1.19.Instantiate one vector and initialize it to the contents of another
16.1.20.Demonstrating STL vector constructors with a user-defined type and showing copying explicitly
16.1.21.Vector Init Array
16.1.22.Demonstrating STL vector constructors with a user-defined type
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.