+ 1

How to align a c++ output at center ?

29th Sep 2019, 6:33 PM
Mohamed Musthafa Suhatha Issath
Mohamed Musthafa Suhatha Issath - avatar
2 Antworten
+ 5
The code below is an example of setw which is a way you can output towards the middle to the best of your ability // setw example #include <iostream> #include <iomanip> //this library is needed for setw using namespace std; int main () { cout << setw (25); //Modify the number to align it to the center cout << "Hello"<< endl; //This outputs Hello towards the middle return 0; } You can try something like setw. More information on setw: https://www.cprogramming.com/tutorial/iomanip.html
29th Sep 2019, 8:12 PM
Glenn 🙏
Glenn 🙏 - avatar