Polak
Polak

Reputation: 23

Why do i get linebreaks?

How can i make it in the same line?

It looks like:

You see a closed door.
It belongs to house 'Magician's Alley 
5a'. 
Nobody owns this house.

But I want it to look like:

You see a closed door. It belongs to house 'Magician's Alley 5a'. Nobody owns this house.

the code:

void House::updateDoorDescription()
{
std::stringstream houseDescription;
houseDescription << "It belongs to house '" << houseName << "'. " << std::endl;

if(houseOwner != 0){
    houseDescription << houseOwnerName;
}
else{
    houseDescription << "Nobody";
}
houseDescription << " owns this house." << std::endl;

HouseDoorList::iterator it;
for(it = doorList.begin(); it != doorList.end(); ++it){
    (*it)->setSpecialDescription(houseDescription.str());
}
}

Upvotes: 2

Views: 63

Answers (1)

Tim
Tim

Reputation: 13258

Because you are doing

<< std::endl

This is endline and puts a linebreak. Remove these and it will be what you want to have.

Upvotes: 4

Related Questions