View previous topic :: View next topic |
Author |
Message |
zhanfeng123 How do I cheat? Reputation: 0
Joined: 20 Jan 2008 Posts: 9
|
Posted: Tue Dec 23, 2008 7:36 pm Post subject: [C++ Help Needed] Solved |
|
|
Code: |
cout<<"Student Name: ";
cin.getline (studName, 21);
cout<<"Student #: ";
cin.getline (studID, 10);
cout<<"Student Age: ";
cin.getline (studAge, 3);
cout<<"Student HomeForm: ";
cin.getline (studHF, 4);
|
When i input a name that is longer than 20 in length, then the program displays Student #, Student Age, Student HomeForm without having the user enter the inputs and the program ends.
My question is how can i fix this problem without having to change the size of the name and others.
Thanks in advance.
Last edited by zhanfeng123 on Tue Dec 23, 2008 10:02 pm; edited 1 time in total |
|
Back to top |
|
|
manc Grandmaster Cheater Reputation: 1
Joined: 16 Jun 2006 Posts: 551
|
Posted: Tue Dec 23, 2008 8:14 pm Post subject: |
|
|
You should post your whole piece of code if you want help.
_________________
|
|
Back to top |
|
|
samuri25404 Grandmaster Cheater Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Tue Dec 23, 2008 9:00 pm Post subject: |
|
|
Code: |
cin.getline( variable, length );
fflush( stdin );
|
_________________
|
|
Back to top |
|
|
zhanfeng123 How do I cheat? Reputation: 0
Joined: 20 Jan 2008 Posts: 9
|
Posted: Tue Dec 23, 2008 10:03 pm Post subject: |
|
|
samuri25404 wrote: | Code: |
cin.getline( variable, length );
fflush( stdin );
|
|
Thanks but it didn't work but I have found another method.
|
|
Back to top |
|
|
Stonehenge Master Cheater Reputation: 0
Joined: 03 Oct 2008 Posts: 280 Location: Unknown Jumphole
|
Posted: Wed Dec 24, 2008 12:37 am Post subject: |
|
|
zhanfeng123 wrote: | samuri25404 wrote: | Code: |
cin.getline( variable, length );
fflush( stdin );
|
|
Thanks but it didn't work but I have found another method. |
Can you put it here so we know what worked?
_________________
|
|
Back to top |
|
|
|