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.

186 questions
-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
  • 63
  • 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
  • 1
  • 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
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
  • 157
  • 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
  • 920
  • 6
  • 14
1 2 3
12
13