Skip to content

Instantly share code, notes, and snippets.

@johnhmj
Created May 2, 2010 12:53
Show Gist options
  • Save johnhmj/387105 to your computer and use it in GitHub Desktop.
Save johnhmj/387105 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <vector>
// Integrated Development Environment
// Visual C++
using namespace std;
// 利用 STL vector
typedef vector<string> Vstr;
//
void main(int argc, char** argv)
{
string _buffer_string;
Vstr vstr;
while ( 1 )
{
cout<<"Input your name: ", cin>>_buffer_string;
// 輸入 -1 即跳出程式
if ( _buffer_string.compare("-1") == 0 )
{
break;
}
vstr.push_back(_buffer_string);
}
for (size_t i = 0; i < vstr.size(); i ++)
{
cout<<(i + 1)<<". "<<vstr[i]<<endl;
}
system("PAUSE");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment