cout Questions
6
Solved
How do you format a float in C++ to output to two decimal places rounded up? I'm having no luck with setw and setprecision as my compiler just tells me they are not defined.
cout << "Total :...
Whew asked 21/1, 2013 at 3:19
6
Solved
I often use cout for debugging purpose in many different places in my code, and then I get frustrated and comment all of them manually.
Is there a way to suppress cout output in the runtime?
And...
2
Solved
I found this question already asked, but the answer everybody gives is
std::cout << std::setw(5) << std::setfill('0') << value << std::endl;
which is fine for positive nu...
17
Solved
I want to work with unsigned 8-bit variables in C++. Either unsigned char or uint8_t do the trick as far as the arithmetic is concerned (which is expected, since AFAIK uint8_t is just an alias for ...
Metaxylem asked 23/3, 2009 at 12:42
3
Solved
I am learning C++. I have a problem formatting the output of my program. I would like to print there columns perfectly aligned but so far I cannot do it, here is my code:
int main()
{
employee em...
3
can't get "wcout" to print unicode string in multiple code pages, together with leaving "cout" to work
please help me get these 3 lines to work together.
std::wcout<<"...
8
Solved
How do I do the following with std::cout?
double my_double = 42.0;
char str[12];
printf_s("%11.6lf", my_double); // Prints " 42.000000"
I am just about ready to give up and use sprintf_s.
More ...
Bari asked 16/8, 2012 at 14:28
1
Solved
I'm wondering what is the efficient and smart way to output a string to console with variables. I know in C++20 there is std::format which makes this easy, but I'm unsure about C++17.
For example, ...
2
Solved
I am learning C++, so you are very right to assume that I am new to C++ and programming as well.
I am trying to understand iostream library, not the whole, but the things that newcomers must know b...
7
I want cout to output an int with leading zeros, so the value 1 would be printed as 001 and the value 25 printed as 025. How can I do this?
Spigot asked 11/11, 2009 at 11:12
7
Solved
Why I cannot cout string like this:
string text ;
text = WordList[i].substr(0,20) ;
cout << "String is : " << text << endl ;
When I do this, I get the following error:
Error...
2
If I want to write my own test.cpp that checks if another .cpp file is outputting the way I want it to output, is there anyway to do it without explicitly printing it?
In other words, is there any...
Pretonic asked 28/10, 2016 at 3:52
4
Solved
Is it possible on Windows without using WinAPI?
2
Solved
First of all, sorry if this is in the wrong category, as I am not sure what the cause of this problem is.
For educational purposes I have created a small "Hello World" application
#include <...
6
Solved
I'm coding a task monitoring, which updates tasks' progress using cout. I'd like to display one task progress per line, therefore I have to rollback several lines of the console.
I insist on "seve...
3
Solved
In this answer we can read that:
I suppose there's little difference between using '\n' or using "\n", but the latter is an array of (two) characters, which has to be printed character b...
Melantha asked 28/7, 2019 at 12:27
2
Is there a way in C++ to tell if std::cout and std::cerr are pointing to the same destination?
That is, I'd like to be able to distinguish when the program is launched like
program or program &g...
2
Solved
Why constexpr does not work with std::cout, but works with printf?
#include <iostream>
constexpr void f() { std::cout << ""; } //error
constexpr void g() { printf(""); } //ok
And why...
2
I'm not new to programming but I am new to C++ using Xcode as the IDE. I am not allowed to use cout << "hello"; to print, the compiler complains and only works when I use std:cout <<. W...
6
Solved
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <ctime>
int main(int argc, char* argv[])
{
std::clock_t start;
double duration;
std::cout << "S...
Aleece asked 20/8, 2012 at 20:6
6
Solved
I understand that to avoid output intermixing access to cout and cerr by multiple threads must be synchronized. In a program that uses both cout and cerr, is it sufficient to lock them separately? ...
Ulphiah asked 1/2, 2013 at 0:16
4
I am writing a sorting program using a host of different functions as y'all can see from
my declarations. However, I keep getting these same errors when I try to compile and run my program
they a...
3
So I have a function (or rather, I'll turn it into a function later) to make a random % progress in a console window; like this:
#include <iostream>
#include <time.h>
#include <cmat...
Kocher asked 19/5, 2013 at 14:33
9
Solved
I am relatively new to the C++ world.
I know std::cout is used for console output in C++. But consider the following code in C :
#include<stdio.h>
int main(){
double dNum=99.6678;
printf(...
© 2022 - 2024 — McMap. All rights reserved.