dimanche 24 juin 2018

c++ Can´t properly fill gab between two strings with dots

sry for bad english. I´m learning for an upcoming exam right now. We are using C++11. And part of the exercise says i need to fill the gab between two strings with dots like this. (Full Exercise is about read & write into a textfile) We are not allowed to use "conio.h" or any C related stuff.

London....................12345
Washington D.C......23456

So that´s what i wrote.

outFilePrefix << countZipCode << endl;  //show amount of zipcode in file
for (const auto& s : myMap) {
   //fill gab between town and area code with '.'
    outFilePrefix << left << setw(35) << setfill('.') 
                    << s.first << s.second << endl;
}
cout << "wrote into file sortedVorWahlen.txt" << endl;
outFilePrefix.close();

But when i check the text file, it shows me a line full of dots between countZipCode and the cities. How can i prevent that from happening? Thanks for the help! how it looks in outputFile

Aucun commentaire:

Enregistrer un commentaire