Trying to get this vector to save a list of names, and then spit it out in all c
ID: 3863260 • Letter: T
Question
Trying to get this vector to save a list of names, and then spit it out in all capitals when making the account. Heres my main file:
Here's the function to display the accounts:
And my output is converting it to capitals, but the first character gets cut out. Here's my output:
As you can see, the characters are converted to capital, but the "n" gets cut off. Thanks
int main declare list of account here. The size of the list is not fixed int input 0; int input Ptr & input while input 6) menu (input Ptr run loop to continue program until terminated by user switch input cases: call functions to perform tasks case 1: make Account break case 2: Print AllAccount break case 3: deposit Account break case 4: withdrawAccount break case 5: print Account break; case 6: breakExplanation / Answer
Hey, This is happening because of your call to cin.ignore() function before your getline() call.
the .ignore() of the istream base class is used When you want to throw away a specific number of characters from the input stream manually.
A very common use case is using this to safely ignore newline characters since cin will sometimes leave newline characters that you will have to go over to get to the next line of input.
cout << "Enter Name: ";
cin.ignore();
getline(cin, add_name);
Will get the name inputted by the user, Ignore the first character, then extract the string to your string.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.