1) Well from what I know, it erases the characters in a string from a starting position ( 0 ) and then it erases so many characters ( 8 ).
2) It clears the whole string?
There is no code there that displays anything.
I'm sorry, I posted the display function in a previous post.
Code:
/***********************************/
/**** Phonebook::DisplayEntries ****/
/***********************************/
void Phonebook::DisplayEntries()
{
if(vEntries.size()==0)
{
cout<<"\n\t\t\t\t >FILE EMPTY<";
cout<<endl<<endl;
cout<<setfill('=')<<setw(80)<<"=";
return;
}
else
{
for(unsigned int i=0;i<vEntries.size();i++)
{
vEntries[i].ordernum=(i+1);
cout<<"\n\t\t\tOrder Number:\t\t"<<vEntries[i].ordernum;
cout<<"\n\t\t\tName:\t\t\t"<<vEntries[i].name;
cout<<"\n\t\t\tCell Phone Number:\t"<<vEntries[i].cnumber;
cout<<"\n\t\t\tHome Phone Number:\t"<<vEntries[i].hnumber;
cout<<"\n\t\t\tAddress:\t\t"<<vEntries[i].address<<endl;
}
cout<<endl;
cout<<setfill('=')<<setw(80)<<"=";
}
}
string str = "start text";
str.clear();
str = "new text";
cout<<str<<endl;
I get what your saying when you make a str = "some text"; which changes the value of str...
But, is this the same thing as STRSTR<<str; in a string stream?
Because the only place that I actually set a string to a string (=) is in the name test.name=first+" "+last.
And like I said before. When I did not use the clear() function in my code... the strings displayed the WHOLE string stream... not just the string i wanted.
Code:
while(getline(fFile,temp.name))
{
getline(fFile,temp.cnumber);
getline(fFile,temp.hnumber);
getline(fFile,temp.address);
// Doesn't display what i want
s.str(temp.name);
s >> heading >> first >> last;
temp.name=first+" "+last;
s.str("");
s.str(temp.cnumber);
s >> heading >> temp.cnumber;
s.str("");
s.str(temp.hnumber);
s >> heading >> temp.hnumber;
s.str("");
s.str(temp.address);
s >> heading >> temp.address;
s.str("");
vEntries.push_back(temp);
And to see if this helps with anything... I will post my .txt file that I am reading from.
Code:
Name: John Doe
Cell Phone Number: 123-4567
Home Phone Number: 890-1234
Address: 123 Abc Dr.
Name: Joe Dirt
Cell Phone Number: 222-2222
Home Phone Number: 333-3333
Address: 131 Yoo Ct.
I mean I could always quit trying with the Formatted Data File and just use characters to divide the strings...like I usually do... but that defeats the purpose of the user being able to keep the .txt file on his desktop and read from it without trouble...