Use toupper function to convert all elements in a char vector to upper case : vector indexer « vector « C++ Tutorial






#include <iostream>
#include <vector>
#include <cctype>
using namespace std;

int main()
{
  vector<char> v(10); // create a vector of length 10

  cout << "Size = " << v.size() << endl;

  for(int i=0; i<10; i++) 
     v[i] = i + 'a';

  cout << "Current Contents:\n";
  for(int i=0; i<v.size(); i++) cout << v[i] << " ";
  cout << "\n\n";
  
  for(int i=0; i<v.size(); i++) 
     v[i] = toupper(v[i]);
  cout << "Modified Contents:\n";
  for(int i=0; i<v.size(); i++) 
     cout << v[i] << " ";
  cout << endl;

  return 0;
}
Size = 10
Current Contents:
a b c d e f g h i j

Modified Contents:
A B C D E F G H I J








16.17.vector indexer
16.17.1.Use indexer to update element in the vector
16.17.2.Use toupper function to convert all elements in a char vector to upper case
16.17.3.Returns all values within a range
16.17.4.Find element in a vector using a linear search