I'm having a problem like so.
stream%26gt;%26gt;FirstName;
stream%26gt;%26gt;LastName;
stream%26gt;%26gt;IDnum;
cout%26lt;%26lt;FirstName%26lt;%26lt;" "%26lt;%26lt;LastName%26lt;%26lt;" "%26lt;%26lt;IDnum%26lt;%26lt;endl;
Instead of outputting something such as
John Smith 45
It outputs this...
45n Smith
For some reason, after the LastName is printed, it goes to the beginning of the buffer and writes over the characters. FirstName and LastName are character arrays and not a strings, and that's what they have to be (class assignment). I've tried flush between LastName and IDnum, but that doesn't seem to work. Whats the problem?
In C++, why is my buffer stream being written over?
You need to show us your initiation statements for FirstName, LastName and Idnum; it looks to me that you have something mixed up while allocating memory for these variables.
Reply:most probably, you have not allocated memory properly for your strings.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment