im new to c++ and recently i made a program my self and got it working but i stumbled upon this char and trouper function as 1 forum user suggest that i use it
here is the code
#include <iostream>
#include <string>
usingnamespace std;
int main ()
{
cout << "This is just for fun survey"<<endl;
cout << " So answer truthfuly"<<endl;
bool answer = false;
string q1;
cout << "What is your name?"<<endl;
getline (cin,q1);
string q2;
cout << "What is your age?"<<endl;
getline (cin,q2);
string q3;
cout << "Are you a Boy or a Girl? answer with B/G" <<endl;
getline (cin,q3);
string q6;
cout << "Do you believe in GOD? answer with Y/N" <<endl;
getline (cin,q6);
if (q3=="B" || q3=="G")
{
string q4;
if (q3=="B")
{
answer = true;
cout << "Did you ever had a girlfriend and loved her?" <<endl;
getline (cin,q4);
}
if (q3=="G")
{
answer = true;
cout << "Did you ever had a boyfriend and loved him?" <<endl;
getline (cin,q4);
}
q3=q3+", "+q4;
}
if (!answer)
q3 = "Please answer properly with B/G and repeat the survey thank you!";
if (q6=="Y" || q6=="N")
{
string q5;
if (q6=="Y")
{
answer = true;
cout << "So you believe in GOD but why?" <<endl;
getline (cin,q5);
}
if (q6=="N")
{
answer = true;
cout <<"So you DONT believe in GOD but why?" <<endl;
getline (cin,q5);
}
q6=q6+", "+q5;
}
if (!answer)
q6 = "Please answer properly with Y/N and repeat the survey thank you!";
cout <<"You are: "<<q1<<endl;
cout <<"Your age is: "<<q2<<endl;
cout <<"You are: "<<q3<<endl;
cout <<"And your belief is: "<<q6<<endl;
system("PAUSE");
return 0;
}
that is not the exact code that he suggests to use a char/trouper function i already fixed it my self..
the thing is he says that in q3 i should have rather use char/trouper function on it..
I should point out that there is a lot reference material on this site, as well as articles, and a tutorial. It is all at the top left of this page. I suggest you have a good read.
Also, Googleing C++ toupper or some other function name works really well.
Probably a good idea to get a good book as well, there are lots of them: some good; some bad. If it was me I would go for something written by one of the big names Bjarne Stroustrup or Herb Sutter come to mind, but there are others.