You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
428 B
C++

Assign elements in vector a value through an iterator
#include <iostream>
#include <vector>
#include <cctype>
using namespace std;
int main()
{
vector<char> v(10); // create a vector of length 10
vector<char>::iterator p; // create an iterator
int i;
// assign elements in vector a value
p = v.begin();
i = 0;
while(p != v.end()) {
*p = i + 'a';
p++;
i++;
}
return 0;
}