To avoid buffer overflow, prefer using
cin.getline(char_ptr, size);
>> With that code, calling the >> operator will always store it into appt.subject, but what about storing information to appt.location? Any suggestions on an approach?
Actually there are more than one ways to do that. Simplest being :
in >> subject >> location
However you get few problems:
1. Cant use space, in strings
2. Buffer overflow
3. Will surely confuse the user
So you print message before every input like you do in normal program:
cout << "\nEnter Location: ";
in.getline(location, 60);
cout << "\nEnter Subject: "
in.getline(subject, 60);
Last edited by vishesh; Nov 4th, 2009 at 6:17 pm.
Reputation Points: 85
Solved Threads: 42
Nearly a Posting Virtuoso
Offline 1,362 posts
since Oct 2006