Ok so I'm new to here but I'm trying to make a game for my project at school the game is going really well but I can't get the input(cin) right when I ask the user to pick a character it works fine but will output the information after the user types the characters name twice i need to resolve this please the deadline is tomorrow also it would help if you told me where I went wrong so I can learn from my mistake here is my games code :
[*Code]
#include <iostream>
#include <string>
using namespace std;
int main(){
cout <<"***********Pick a side*************"<< endl;
cout << "1) Team A \n"
"2) Team B \n"
"3) Team C \n"
"4) Team D \n"
"5) Team E \n"
"6) Team F \n"
" \t (Press a team's letter to pick)" << endl;
"More Info: Saitama (サイタマ, Saitama) is the main protagonist of One-Punch Man and so far the most powerful hero alive in the series. Saitama faces a self-imposed existential crisis, as he is now too powerful to gain any thrill from his deeds.[3]\n\n"
"Initially just a hero for fun,[4] he later registers into the Hero Association as a professional hero,[5] currently B-Class Rank 7,[6] and defends his home in Z-City from Mysterious Beings.[7] Under the Hero Association, he is given the name Caped Baldy (ハゲマント, Hagemanto; Viz: Bald Cape).[8]";
cout<<"Well picked!! Goku is strong enough talking here is his abilites, stats and info:\n\n"
"Health = 8000/8000\n\n"
"Race = Saiyan \n\n"
"Gender = Male\n\n"
"Date of birth = Age 736,Age 737(anime)\n\n"
"Date of death = October 12, Age 761\n\n(revived on November 2, Age 762)\n\n"
"(May 26, Age 767)\n\n(revived on May 8, Age 774)\n\nAge 779 (altered history; time reversed, death undone)\n\n"
"Height = 5'9 (175 cm) (*adult*)\n\n"
"Weight = 136 lbs (62 kg) (*adult*)\n\n"
"Address = 439 East District\n\n"
"Occupation = Martial Artist Firefighter \n\n" "(Goku's Fire Brigrade)" "Farmer\n\n"
"Security Guard\n\n"
"Allegiance = Dragon Team\n\n"
"Turtle School (formerly)\n\n"
"Team Universe 7\n\n"
"Time Patrol\n\n"
"More info:\n\n";
cout << "Son Goku (孫そん悟ご空くう Son Gokū), born Kakarot (カカロット Kakarotto), is a male Saiyan and the main protagonist of the Dragon Ball series.\n\nGoku is a Saiyan originally sent to Earth as an infant with the mission to destroy it, an accident alters his memory.\n\nallowing him to grow up to become Earth's greatest defender, as well as the informal leader of the Dragon Team.\n\nThroughout his life, he constantly strives and trains to be the greatest warrior possible and to fight stronger opponents, which has kept the Earth and the universe safe from destruction many times."<< endl;
Edit your post (bottom-right corner) and add [code] and [/code] tags so that your code is more pleasant to look at.
but will output the information after the user types the characters name twice
Did you write this code? You are calling getline 3x times. It sounds like you want the player to type in 1 name, so why do you call getline 3 times? The other problem is that mixing getline and cin can lead to some weird behavior when newlines are kept in cin's buffer.
Add a cin.ignore() before your calls to getline to remove the newline.
1 2
cin.ignore()
getline(cin,anime_Character);
Then, compare anime_Character to "kenaki" or "Goku", or whatever.
Step one is to edit your OP post like I said, by formatting your code. Step two is to remove the multiple getline calls and just have the cin.ignore(); followed by getline(cin, anime_Character).
Then, instead of checking if goku_Dbz == "Goku", have anime_Character == "Goku"
So should i write
cin.ignore();
getline(cin,anime_Character);
keep doing it for the rest? and please i don't want to bother you but what do you mean OP post im scratching my head all over it Thank you you helping me alot!!!
I meant your first post. Go to the "Edit" button at the bottom of it, and add [code] before the start of your code, and [/code] after your code ends, so that your code gets formatted correctly.
Read the tutorial on control I posted, and try to fix your code, and if you still can't figure it out, post what you tried.
It seemed to work Thanks your a lifesaver i can't thank you more not in a million years would i be able to have solved that without you guidance and help Thanks for everything!!!!