lundi 18 janvier 2021

How to use setw() in c++. Here is my code using setw(). It is not giving desired results

for(int i=0;i<arr;i++)
        {
            cout <<left<<setw(25);
            cout<< names[i]<< " " <<age[i];
            cout <<setw(25);
            cout<< fname[i]<<endl;
        }

here arrays names,age and fname contains name, age and father's name respectively. output of my code is:

zeel dev                 18r k sanghai
amar singh               25r k sanghai
alex pandit              52s n vardhan

after age column i want a gap of another 25 column. How to do it? setw() is not working properly.

Aucun commentaire:

Enregistrer un commentaire