Paragraph alignment question

Hey guys i'm working on a project that involves the user submitting a paragraph to me and then asking them to choose which alignment option they would like(see code) the problem is i can't the alignments to work and i'm pretty stumped, i tried checking out a different page that showed me how but its still not working. any help would be awesome!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;


int main()
{
	std::string paragraph;
	std::cout<<" Please, enter a full paragraph: ";
	std::getline (std::cin,paragraph);



	int adjustment = 0;
	cout << " Please give me a numerical number from 1 to 4 for how you would like your paragraph to be formatted " <<"\n"<<"1.Left aligned, 2.Right aligned, 3.Center aligned, 4.Justify aligned: ";
	
	cin >> adjustment;

	switch(adjustment)
	{
		case 1 :
		std::cout.width(6); std::cout << left << paragraph << "\n";
		break;
		case 2 :
		std::cout.width(6); std::cout<< right  << paragraph << "\n";
		break;
       		case 3 :
		std::cout.width(6); std::cout<< setw(20)<< paragraph << "\n";
		break;
		case 4 :
		std::cout.width(6); std::cout<< std::internal << paragraph << "\n";
		break;
		default :
		cout<<"Please enter a number from only 1 to 4"<<endl;
	}

  	
	return 0;
}
The alignment settings for iostreams are for controlling the format of output within a field of a particular size (or width.) They are not sufficient for formatting paragraphs.

If the size (width) is smaller than the length of the output, it is ignored.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// http://ideone.com/nnb0Ro
#include <iomanip>
#include <iostream>
#include <string>

void right_align(const std::string& content, unsigned field_width) {
    std::cout << std::quoted(content) << " right aligned in a field of size " << field_width << '\n';
    std::cout << "|" << std::right << std::setw(field_width) << content << "|\n\n";
}

void left_align(const std::string& content, unsigned field_width) {
    std::cout << std::quoted(content) << " left aligned in a field of size " << field_width << '\n';
    std::cout << "|" << std::left << std::setw(field_width) << content << "|\n\n";
}

int main() {
    right_align("*", 20);
    left_align("*", 20);

    std::cout << '\n';

    right_align("*****", 1);
    left_align("*****", 1);
}
i understand what you are putting but i'm not quite sure how you would add this into the case statement while still prompting them for a paragraph, still quite new to c++
If you want to format paragraphs, you need to do it yourself. As I mentioned:
cire wrote:
The alignment settings for iostreams are for controlling the format of output within a field of a particular size (or width.) They are not sufficient for formatting paragraphs.
Topic archived. No new replies allowed.