Is there a way to center align "text"using cout<< in regards to the console screen position?

thanks

Recommended Answers

All 2 Replies

Find the length of the text. Subtract that from the width of the output line (usually 80 in a console window). Output half that number blanks before outputting the text, or use setw( ).

Find the length of the text. Subtract that from the width of the output line (usually 80 in a console window). Output half that number blanks before outputting the text, or use setw( ).

of course u should include:

#include <iomanip>

otherwise wont work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.