Home » C++ Programming » Strings » Question
  1. What is the output of this program?
    #include <iostream>
    #include <string>
    using namespace std;
    int main ()
    {
    string str ("Testing str...");
    for ( string :: iterator Iter = str.begin(); Iter != 5; ++Iter)
    cout << *Iter;
    return 0;
    }
    1. Compilation Error
    2. Testing str...
    3. Runtime Error
    4. Garbage value
    5. None of these
Correct Option: A

In the for loop, We are not allowed to give a numeric value in string, So it is arising an error.



Your comments will be displayed only after manual approval.