关于vector容器的一些函数用法:push_back; at; back; pop_back。
#include “string”
#include”iostream”
#include”vector”
using namespace std;
int main(int argc, char **argv)
{
string str;
vector vectStr;
while (cin>>str)
{
if (“111” == str)
{
break;
}
vectStr.push_back(str);
}
if (!vectStr.empty())
{
int size = vectStr.size();
for (int i=0; i<size; i++)
{
string str;
//str = vectStr.at(i);
str = vectStr.back();
vectStr.pop_back();
printf("str = %s\n", str.c_str());
}
}
return 0;
}