strings

Hey,

I ve pretty much just extended the example givin in the tutorial on this site, I was wondering if i could get the program to say the persons name from the 7 th line in the program to the 18th line in the program, i ve also labled where i want it

#include <iostream>
#include <string>
using namespace std;

int main ()
{
string mystr;
cout << "What's your name? ";
getline (cin, mystr);
cout << "Hello " << mystr << ".\n";
cout << "What is your favorite team? ";
getline (cin, mystr);
cout << "I like " << mystr << " too!\n";
cout << "Whose your favorite player? ";
getline (cin, mystr);
cout << "Get Otta here!!! " << mystr << " my fav 2, lol. ";
cout << "Howd they go on the wkend? ";
getline (cin, mystr);
cout << mystr << " Really!, geez i missed a bit << // there name here



system ("pause");
return 0;
}



Thanks 4 that
Please edit your post to put your code in correct tags as explained http://www.cplusplus.com/forum/articles/1624/

Then we will be happy to help :)
Z.
hey

Sorry i didnt know bout that
lol


#


int main ()
{
string mystr;
cout << "What's your name? ";
getline (cin, mystr);
cout << "Hello " << mystr << ".\n";
cout << "What is your favorite team? ";
getline (cin, mystr);
cout << "I like " << mystr << " too!\n";
cout << "Whose your favorite player? ";
getline (cin, mystr);
cout << "Get Otta here!!! " << mystr << " my fav 2, lol. ";
cout << "Howd they go on the wkend? ";
getline (cin, mystr);
cout << mystr << " Really!, geez i missed a bit << // there name here



system ("pause");
return 0;
}



#
1
2
3
4
5
6
7
string mystr;
cout << "What's your name? ";
getline (cin, mystr);
cout << "Hello " << mystr << ".\n";
// etc
getline (cin, mystr);
cout << mystr << " Really!, geez i missed a bit << // there name here 


Could be:
1
2
3
4
5
6
7
string mystr, name;
cout << "What's your name? ";
getline (cin, name);
cout << "Hello " << name<< ".\n";
// etc
getline (cin, mystr);
cout << mystr << " Really!, geez i missed a bit << name << endl; 


Before your code put [c0de] (with o not 0) and after it put [/c0de] (with o not 0)
Last edited on
Thanks 4 that, and your help the other times, lol
Topic archived. No new replies allowed.