Questions tagged [iomanip]

Anything related to C++ I/O manipulators, i.e. special kinds of objects that alter the behavior of streams. Inserting a manipulator into an output stream or extracting one from an input stream provides an easy alternative for configuring specific aspects of the stream operations.

Anything related to C++ I/O manipulators, i.e. special kinds of objects that alter the behavior of streams. Inserting a manipulator into an output stream or extracting one from an input stream provides an easy alternative for configuring specific aspects of the stream operations.

Simple manipulators are defined directly in the C++ standard header <iostream>. Manipulators taking arguments (i.e. functions that return actual manipulator objects) are defined in the <iomanip> standard header.

See CPPreference.com documentation for I/O manipulators.

164 questions
0
votes
0 answers

C++ Word Wrap Within Column

I need to output some columns in c++ that look like this: Lower Upper Line case case Digits Spaces Other ------ ------ ------ ------ ------ ------ To print out some results from a file read, etc, etc. Is there anyway to do…
apttap
  • 458
  • 2
  • 7
  • 17
0
votes
1 answer

C++ template method to choose correct way of printing data

I have a program, written in C++, that uses matrices and I would like to print them out. In the program, matrices are either of type integer or unsigned char. This is the code I'm using right now to do the printing. template void…
martega
  • 1,975
  • 2
  • 19
  • 30
0
votes
1 answer

Iomanip errors with std::left/right

I'm trying to left justify one side of a line and right justify the other side of the line, but im having trouble getting the right side to right justify. Could anyone catch my error? //The following program will declare #include #include…
Syntactic Fructose
  • 15,445
  • 16
  • 74
  • 158
-1
votes
0 answers

Aligning Data tables in C++ output

I have been trying to align these data elements in the output screen using \t and setw but I have not been able to crack it. I do not want the table alignment to change based on the number of characters in these elements. Please help! Here is the…
-1
votes
0 answers

Initializing 3D array with .dat file in C++

I'm new to C++ and I've got trouble understanding how to manage the following problem : I have a .dat file containing multiples lines alike "i j value" and I must create an array that i will call test where test[i][j]=value. Could you help me figure…
HugZzZ
  • 1
-1
votes
2 answers

c++ ostream output with setw

I have an output file name out using the below code to add a string to the text file: string foo = "Hello, foo"; out << foo; How can I customize a string to input into out file adding string and numbers with a specific width using setw(7) Your…
Adam Tr.
  • 9
  • 4
-1
votes
2 answers

set precision return statement C++

I want to return a double from a function with a set precision! It is that possible ? I want an accuracy of 10-5 ! For example : double f(double a ,double b) { //something like return.setprecision(6); return (a+b)/2; }
Vasiu Alexandru
  • 43
  • 1
  • 13
-2
votes
2 answers

Can I set a variable that will change the floatfield when using cout?

I want to be able to easily change the floatfield from scientific to fixed dependent on a condition, so my result would change from something like 3.000000e+00 to 3.0, using code that might look something like this: some_datatype floatfield; float…
David
  • 43
  • 5
-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
1 answer

Why are these C++ Commands looked down upon?

I know many people have suggested to me to not use code such as using namespace std; or system ("pause"); system ("cls"); system ("color f0");//and other system commands or goto TitleScreen; goto DeathScreen; or break; and I'm just wondering why…
Andrew Tew
  • 47
  • 8
-3
votes
1 answer

Rounding decimal to tenth but showing hundredth in c++

I've been working on this homework assignment for a while and am about ready to pull my hair out. I need help rounding a float to the tenths place while still showing a 0 in the hundredths place and nothing I do seems to do that. i.e. 2.47 =…
Clueless
  • 1
  • 1
-4
votes
0 answers

C++ code showing different outputs for same arithmetic operation performed in a different way

I was solving a basic problem in which I've been given the quantity and price (per item) of certain product that somebody needs to purchase. If the quantity is more than 1000 (strictly), then additional 10% discount is to be given. In this, I have…
-4
votes
3 answers

Having the following error when trying to implement a method of class using list in C++!

Edit 1 Initial idea: MAIN.CPP: #include #include "Cars.h" #include "Dealer.h" #include "Manufacturer.h" #include #include #include #include #include #include using namespace…
madeluccar
  • 137
  • 1
  • 1
  • 8
-9
votes
1 answer

The C++ equivalent of C's format string

I have a C program that reads from keyboard, like this: scanf("%*[ \t\n]\"%[^A-Za-z]%[^\"]\"", ps1, ps2); For a better understanding of what this instruction does, let's split the format string as follows: %*[ \t\n]\" => read all spaces, tabs and…
user7140484
  • 890
  • 6
  • 12
1 2 3
10
11