+ 1
How to align a c++ output at center ?
2 odpowiedzi
+ 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