I have a problem. My code can read a line of sentence but when i try to print them the white spaces seperates them. here's my code:
void viewRec()
{
recordlol record;
int choice;
system("cls");
ifstream fin("Rec.txt");
record.firstname;
record.lastname;
record.address;
cout << "\n_________________________________RECORD'S LIST_________________________________\n\n";
cout << "First Name: Middle Name: Last Name: Address: Contact Number: Age:";
cout << "\n---------------------------------------------------------------------------------------------------------------------------------------------------------\n";
if (fin.is_open())
{
while (fin >> record.firstname >> record.middlename >> record.lastname >> record.address >> record.contact >> record.age)
{
cout <<"\n"<<setw(11) << record.firstname;
cout << setw(27) << record.middlename;
cout << setw(25) << record.lastname;
cout << setw(19) << record.address;
cout << setw(30) << record.contact;
cout << setw(20) << record.age;
}
fin.close();
}
else
{
cout << "File is not open!" << "\n";
}
//how to make the reading include the whitespaces? :D
Post the Output: I'm not exactly sure what you mean.