Loop through the string array : string « String « C++






Loop through the string array

  
 

#include <iostream>
#include <list>
#include <algorithm>
#include <string>

using namespace std;

int main( ) {
   string arrStr[5] = {"A", "B", "C", "D", "E"};

   for (string* p = &arrStr[0]; p != &arrStr[5]; ++p) {
      cout << *p << endl;
   }

}

/* 
A
B
C
D
E

 */        
    
  








Related examples in the same category

1.Define a string variable, assign a value and display it
2.string basics
3.copy constructor
4.Changing Case in Strings
5.A short string demonstration.A short string demonstration.
6.Extracting Words in Strings Delimited by Whitespace
7.Char Escapes