You are viewing a single comment's thread. Return to all comments →
Please can someone explain me the code ,i have never used this kind of definition of string . And could someone please tell if there is any method to do it using setw() ,setfill() and stuff ,although i think setfill() wouldnt be required .
I just finished with the one that uses setw
cin >> n;
auto width = n;
cout << setw(width) << string(width - n, '#') << endl;
Could use s.substring(0, witdth - n, '#') from string s(width, '#'). Not sure if compiler would generate different code.