Questions tagged [setw]

`std::setw` is a `C++` function used to sets the field width to be used on output operations.

Defined in the <iomanip> include file. See C++ reference page on setw.

119 questions
0
votes
1 answer

I am just plain confused

My teacher keeps telling me that me that I MUST have the setw on the same line as the item that is being modified. I thought that I did but she keeps telling me its not and she also keeps telling me that I am labeling my parameters wrong so if…
Geoff
  • 1
  • 2
0
votes
3 answers

Format C++ Output Columns, Limiting Each Field

I have an assignment where I am required to output an array which contains information about songs. The problem I am having is formatting the output. My assignment specifies the length of each field that is displayed but I cannot find a good way to…
David tftyfy
  • 5
  • 1
  • 4
0
votes
1 answer

can't get setw to line up

I'm not sure how to go about lining this up better. I thought by using L = name.length(); and subtracting that from the setw it would line up better but nope. I have name and ID set correctly but I can't seem to get the rest to line up. These are…
softsound
  • 29
  • 3
0
votes
1 answer

std::setw() inserts a \0 at the end of my array

input = new char[64](); std::cout << "wait for cin" << std::endl; while (std::cin >> std::setw(64) >> input) { std::cout << "input : " << input << std::endl; ... Well I assure you setw() copies 63 characters to the char * input instead of…
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
-1
votes
2 answers

Can't for the life of me get this to align in C++

been trying to get this to align, and every source has told me to use left and setw, but no matter how I format it I can't seem to get it to work. Anyone have any ideas? #include #include #include using namespace…
-1
votes
1 answer

How to get value for each attribute when file was save with setw() function

I'm a newbie of C++. I'm sorry if my question have any errors. I have a file with 4 attributes: Name, Position, Birthday, Salary And i use setw() function to save file.txt with format like this NAME POSITION BIRTHDAY …
Phi Dinh
  • 1
  • 3
-1
votes
2 answers

Setting up precision C++

So, i'm attempting to set the precision for input values in my code. I want the values to be printed with two decimal points afterwards of precision though i'm not exactly sure how. Here's my code. #include #include float…
Granzo
  • 59
  • 1
  • 7
-1
votes
1 answer

setw gives extra space after first loop

How do I stop setw() from creating space after an endl? My first loop here which displays my column headers works fine, but on my second loop (which displays data), I get a large blank space before it shows the first line. I have tried clearing the…
-1
votes
1 answer

Issues with setw in c++

Hi first here is my program i want to make all the output of my program is segregate in column Here is the Output of my program right now i want to make the output is all line in in age and section: #include #include using…
-1
votes
2 answers

C++ multiline text blocks

I've to create a sort-of Christmas greeting card which needs to include designs generated using nested-for loops. The output needs to have a border on all four sides with variable text inside along with the nested-for loop designs. Something along…
doberoi96
  • 413
  • 6
  • 22
-1
votes
1 answer

C++ justification in multiple columns

I am trying to write a program to display an account balance each month and am having an issue getting 3 columns to justify correctly. The output expected should look like: Total Month Accumulated ------ …
Sarah Koch
  • 11
  • 4
-2
votes
2 answers

Right justify two variables in C++ (I want to treat them as one variable)

Let's say I have a char variable, and an integer variable. I want to treat them as one variable when I'm outputting them (ex: B6, A2, C10, etc) I want to right justify both of these variables in a 4 space slot, but I can't for the life of me figure…
-2
votes
2 answers

using setw to build a pyramid

My output is supposed to be four triangles and a pyramid. I managed to get the four triangles but can't figure out the pyramid. Any help would be great. (I also have to use setw and setfill). The output is a left aligned triangle, then left aligned…
Ace
  • 59
  • 1
  • 7
-6
votes
2 answers

No operator ">>" matches these operands

I've done some digging on this question and have found other people with similar, but non-identical errors to me. My two top theories are that I'm missing something obvious or I've broken Visual Studio. The code runs as follows: //…
1 2 3 4 5 6 7
8