Give me a hand on this one
can somebody tell me why this code doesnt work?:
char job[30];
char background[50];
cout << endl << "Occupation?:";
cin.ignore(30, ''\n'');
cin.getline(job, 30);
cout << endl << "Now enter a brief description of your character:" <<endl;
cin.ignore(50, ''\n'');
cin.getline(background, 50);
cout <<endl<< background;
cout <<endl<< job;
getch();
The first cin.getline seems to work, but the second one seems to mess up....
If a seasoned programmer could plug this into his\her compiler and give me some professional feedback, Id be very
happy.
Thanks
Arggggghh!!
Does anyone else find that its sometimes a bitch to paste code on gamedev? This is what it should have looked like....if this works..
char job[30];
char background[50];
cout << endl << "Occupation?:";
cin.ignore(30, ''\n'');
cin.getline(job, 30);
cout << endl << "Now enter a brief description of your character:" < cin.ignore(50, ''\n'');
cin.getline(background, 50);
cout < cout <
getch();
Sorry
Does anyone else find that its sometimes a bitch to paste code on gamedev? This is what it should have looked like....if this works..
char job[30];
char background[50];
cout << endl << "Occupation?:";
cin.ignore(30, ''\n'');
cin.getline(job, 30);
cout << endl << "Now enter a brief description of your character:" < cin.ignore(50, ''\n'');
cin.getline(background, 50);
cout < cout <
getch();
Sorry
If I understand correctly what you are trying to do, the following should work just fine!
#include
#include
int main()
{
char job[30];
char background[50];
clrscr();
cout << endl << "Occupation?:";
cin.getline(job, 30);
cout << endl << "Now enter a brief description of your character:";
cin.getline(background, 50);
cout << endl << endl << "Occupation: " << job << endl << "Description: " << background;
getch();
return 0;
}
Hope this helps!
..-=ViKtOr=-..
#include
#include
int main()
{
char job[30];
char background[50];
clrscr();
cout << endl << "Occupation?:";
cin.getline(job, 30);
cout << endl << "Now enter a brief description of your character:";
cin.getline(background, 50);
cout << endl << endl << "Occupation: " << job << endl << "Description: " << background;
getch();
return 0;
}
Hope this helps!
..-=ViKtOr=-..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement