Question: I use vb C++, i want to do function to center any text in screen (horizontal) screen have 80 spaces to write anything, for example

I use vb C++, i want to do function to center any text in screen (horizontal) screen have 80 spaces to write anything, for example i want to center:
printf("Hello !!");
Or printf("Good Morning");
The output should print anyone of them in the middle of screen, is there anyway to do that without putting space each time??
I think we can use function to count characters in printf then use this ((80- characters number)/2) to put spaces in the right and left so whatever in printf will be centered ?
Idk how whatever any help?? Im new in programming.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!