Iterators in string class

when we used iterators for iterating the characters of the string , why do we declare the datatype of iterator as ‘auto’?
what does ‘auto’ datatype mean?

The auto keyword specifies that the type of the variable that is begin declared will automatically be deduced from its initializer and for functions if their return type is auto then that will be evaluated by return type expression at runtime.

for example

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

int main() {
vector vec(10); // Auto deduce type to be iterator of a vector of ints.
for(auto it = vec.begin(); it != vec.end(); vec ++)
{
cin >> *it;
}
return 0;
}

i got that iterator gets to know datatype by value on right hand side. In your example is vec a array and iterator is used to take input ? what is vector header file for?

vectors are a datatype in c++ that are dynamic arrays, you will learn more about them further in the course. For now, just know that vector and string have a lot of common properties.
in this example, iterator iterartes over all the indices of the vector and takes input for each one (just like you would iterate over an array to take inputs)