Skip to content

Instantly share code, notes, and snippets.

@bitwiser
Last active August 29, 2015 13:56
Show Gist options
  • Save bitwiser/9225314 to your computer and use it in GitHub Desktop.
Save bitwiser/9225314 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<vector>
using namespace std;
int main(){
cout<<"witness my exciting first use of vectors!\n";
cout<<"Enter as many letter as you like, enter ! to quit.\n";
char ch;
vector<char> v;
while(true){
cout<<"enter a letter: ";
cin>>ch;
if(ch=='!')
break;
v.push_back(ch);
}
cout<<"\nGreat! you entered: ";
for(int i=0;i<v.size();i++){
cout<<v[i];
}
cout<<"\nThe first character is : "<<v[0]<<endl;
cout<<"The last character is : "<<v[v.size()-1]<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment