Setfill Command

Can I give space in within setfill command? I wanted to write like this with space * * * *
But not like this **** without space.
Here is my code.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	cout << setfill('*') << setw(34);
	cout << "\n";


	// System Commands
	cout << endl << endl << endl;
	system("pause");
}
Last edited on
You're going to have to write a proper loop.
https://www.cplusplus.com/forum/beginner/273474/

But according to assignment, I have to write it with manipulator functions.

I have to write this with manipulator function.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Programming Assignment 1 *
* Computer Programming I *
* Author: ??? *
* Due Date: Thursday, Jan. 24 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Last asterisk are aligned just like the first asterisks but this website changed the position of last asterisks

Ok my bad, there was no space between asterisks.

But how to write this assignment with manipulator functions?
Last edited on
Like this?

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Programming Assignment 1                                        *
* Computer Programming I                                          *
* Author: ???                                                     *
* Due Date: Thursday, Jan. 24                                     *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Use the [code][/code] or [output][/output] tags to show us exactly what you're trying to achieve.

But
1
2
std::string s = "Programming Assignment 1";
std::cout << "* " << s << setw(40-s.length()) << "*" << std::endl;
Yes like yours one.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                           Programming Assignment 1                        *
*                             Computer Programming I                         *
*                                       Author: ???                                   *
*                           Due Date: Thursday, Jan. 24                      *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Asterisk problem is still there even after using output tag.

Thanks.
Last edited on
Topic archived. No new replies allowed.