for 对vector类型进行循环输出

#include 
using namespace std;
int main(void)
{    vector svec;  
    svec.push_back("I");  
    svec.push_back("LOVE");  
    svec.push_back("C++");
    for (vector::size_type ind = 0;ind != svec.size(); ++ind) {
	cout << svec[ind]; // print current element
	// if not the last element, print a space to separate from the next one
		if (ind + 1 != svec.size())
		cout << " ";
	}
return 0; 
}

你可能感兴趣的:(※【c++】)