t71.stringclassandstringfunction

1
#include<iostream> #include<string> //gives you string functions using namespace std; int main(){ string bucky; cin>>bucky; //end of input is determined by white space cout<<"the string i entered is:"<< bucky<< endl; string x; getline(cin,x); //the end of the input is determined by a new line cout<<x<<endl; string s1("hampster "); string s2; string s3; s2 = s1; //identical things s3.assign(s1); cout<< s1 << s2 << s3 << endl; string s1 = "omgwtfbbq"; cout << s1.at(3) << endl; //strings are array of characters for(int x=0; x<s1.length();x++){ cout<<s1.at(x); } }

Upload: tim-acosta

Post on 09-Apr-2016

212 views

Category:

Documents


0 download

DESCRIPTION

asd

TRANSCRIPT

Page 1: T71.StringClassandStringFunction

#include<iostream>#include<string> //gives you string functionsusing namespace std;

int main(){

string bucky; cin>>bucky; //end of input is determined by white space cout<<"the string i entered is:"<< bucky<< endl; string x; getline(cin,x); //the end of the input is determined by a new line cout<<x<<endl;

string s1("hampster "); string s2; string s3; s2 = s1; //identical things s3.assign(s1);

cout<< s1 << s2 << s3 << endl; string s1 = "omgwtfbbq"; cout << s1.at(3) << endl; //strings are array of characters for(int x=0; x<s1.length();x++){ cout<<s1.at(x); } }