Can anyone tell me how to read in a string into a vector? I know that if I use cin (as I did below) it will not read whitespaces. But if I use cin.getline, cin.get or gets it gives me an error because of the subscript (which I need) and if I take it out, it tells me that my members are not part of my vector!
I've had this problem before but for some reason I always draw a blank when I encounter it. Can anybody point me in the right direction?
Code:void FullName(vector<Names>& Access, vector<Entry>& Process, int& i) // Pre condition: User has entered A in the menu // Post condition: will return the full name to the Add function { cout << "\nYou have chosen to add an entry.\n\n"; cout << "Please enter the last name: "; cin >> Access[i].lastName; cout << "\n\nPlease enter the first name: "; cin >> Access[i].firstName; cout << "\n\nPlease enter the middle initial: "; cin >> Access[i].middleIni; Process[i].fullName= Access[i].lastName+ " " + Access[i].firstName+ " " + Access[i].middleIni; Add(Access, Process, i); } // End FullName function



LinkBack URL
About LinkBacks


