Paragraph Alignment not working

Hi i'm working on a project that involves you asking the user for a paragraph response and then having them choose what alignment they want, i have everything i need it just won't align properly :/ any ideas why?

#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;
}
Last edited on
Duplicate. Please address replies to:
http://www.cplusplus.com/forum/beginner/204151/
Topic archived. No new replies allowed.