cout Questions

16

I have been coding in C++ for a long time. I always wondered which has a faster execution speed printf or cout? Situation: I am designing an application in C++ and I have certain constraints such ...
Excepting asked 22/5, 2009 at 6:55

18

What is the difference between printf() and cout in C++?
Profligate asked 20/5, 2010 at 9:42

11

I want to do: int a = 255; cout << a; and have it show FF in the output, how would I do this?
Brownout asked 26/1, 2009 at 10:37

11

Solved

What do I have to do so that when I string s = "."; If I do cout << s * 2; Will it be the same as cout << ".."; ?
Lavabo asked 7/8, 2012 at 9:44

11

Solved

I am trying to print a Russian "ф" (U+0444 CYRILLIC SMALL LETTER EF) character, which is given a code of decimal 1092. Using C++, how can I print out this character? I would have thought ...
Realgar asked 18/8, 2012 at 3:23

9

Solved

I wrote a simple program that sets a value to a variable and then prints it, but it is not working as expected. My program has only two lines of code: uint8_t a = 5; cout << "value is &...
Tardigrade asked 24/10, 2013 at 9:30

33

Solved

How do I print out the contents of a std::vector to the screen? A solution that implements the following operator<< would be nice as well: template<container C, class T, String delim = &q...
Anchovy asked 25/5, 2012 at 7:13

33

Solved

How do I print out the contents of a std::vector to the screen? A solution that implements the following operator<< would be nice as well: template<container C, class T, String delim = &q...
Acetal asked 25/5, 2012 at 7:13

6

I am working on below code: #include<iostream> #include<stdio.h> using namespace std; main() { unsigned char a; a=1; printf("%d", a); cout<<a; } It is printing 1 and some...
Misesteem asked 23/3, 2013 at 9:38

9

Solved

double x = 1500; for(int k = 0; k<10 ; k++){ double t = 0; for(int i=0; i<12; i++){ t += x * 0.0675; x += x * 0.0675; } cout<<"Bas ana: "<<x<<"\tSon fai...
Breaker asked 6/3, 2011 at 17:13

12

Solved

I'm using Qt4 and C++ for making some programs in computer graphics. I need to be able to print some variables in my console at run-time, not debugging, but cout doesn't seem to work even if I add ...
Drayage asked 7/10, 2010 at 21:43

6

Solved

I saw this question already on this forum but I do not know why the proposed answer does not work in my case. So I try to ask for other slution. I just got my Qt creator running under Linux. I do n...
Capillaceous asked 27/9, 2011 at 8:4

4

Solved

I have difficulties in understanding the sequence of calls in the code below. I was expecting to see the output below A1B2 While I can see that the output I get is BA12 I thought that the c...
Flight asked 11/2, 2013 at 10:11

5

Solved

I am using a fold expression to print elements in a variadic pack, but how do I get a space in between each element? Currently the output is "1 234", the desired output is "1 2 3 4" template<t...
Trotskyism asked 11/7, 2018 at 9:23

16

Solved

In my earlier question I was printing a double using cout that got rounded when I wasn't expecting it. How can I make cout print a double using full precision?
Koosis asked 16/2, 2009 at 18:15

0

#include <bits/stdc++.h> using namespace std; int f(int x) { int n; if(x>0) { if(x%2==0) { cout<<x%10; n=1+f(x/10); } else { n=1+f(x/10); cout<<x%10; } return n; ...
Aube asked 1/6, 2022 at 8:6

6

Solved

Shall this be the example: #include <iostream> using namespace std; int main() { cout << "Hola, moondo.\n"; } It throws the error: gcc -c main.cpp gcc -o edit main.o main.o...
Murray asked 30/1, 2015 at 13:20

4

Solved

Im trying to print a string to console in c++ console application. void Divisibility::print(int number, bool divisible) { if(divisible == true) { cout << number << " is divisible by...
Headless asked 25/2, 2013 at 16:34

4

I am looking for an example that differentiates between cerr and cout in C++? When do I need to use cerr?
Drosophila asked 4/10, 2014 at 9:28

2

I want to cout a table like output using c++. It should look like this Passes in Stock : Student Adult ------------------------------- Spadina 100 200 Bathurst 200 300 Keele 100 100 Bay 200 200 ...
Susansusana asked 18/9, 2014 at 16:39

7

Is there a way to align text when printing using std::cout? I'm using tabs, but when the words are too big they won't be aligned anymore. Sales Report for September 15, 2010 Artist Title Price Gen...
Hearing asked 21/3, 2010 at 4:43

2

Solved

Is there a way to print the value of a constexpr or #defined value at compile time? I want the equivalent of std::cout <<, or some way to do something like constexpr int PI_INT = 4; static_a...
Fiesole asked 20/11, 2012 at 1:34

2

Solved

I want to truncate a string in a cout, string word = "Very long word"; int i = 1; cout << word << " " << i; I want to have as an output of the string a maximu...
Reconstructive asked 25/10, 2013 at 4:2

6

Solved

Is there a more straight-forward way to do this? for_each(v_Numbers.begin(), v_Numbers.end(), bind1st(operator<<, cout)); Without an explicit for loop, if possible. EDIT: How to do this f...
Thagard asked 11/11, 2010 at 9:50

6

Solved

So, I have this question. Why does cout throws error C2065: 'cout' : undeclared identifier I am using Visual Studio 2012 as an IDE and I am writing a school project. I have everything done exce...
Marsiella asked 31/5, 2013 at 13:41

© 2022 - 2024 — McMap. All rights reserved.