cout Questions

2

Solved

Can anyone explain the output of the following program: #include <iostream> using namespace std; int main() { int test = 0; cout << "First character " << '1' << endl; c...
Mornay asked 3/5, 2015 at 20:11

8

Solved

I noticed if I print out a long string(char*) using cout it seems to print 1 character at a time to the screen in Windows 7, Vista, and Linux(using putty) using Visual C++ 2008 on Windows and G++ o...
Gamba asked 15/11, 2009 at 1:28

5

Solved

I've been moving back and forth with Java/C++ so I messed up with my console output and accidentally wrote lines like: cout << "num" + numSamples << endl; cout << "max" + maxSamp...
Giraud asked 17/4, 2015 at 22:14

3

char p; cout << &p; This does not print the address of character p. It prints some characters. Why? char p; char *q; q = &p; cout << q; Even this does not. Why?
Orthocephalic asked 21/3, 2015 at 22:12

2

Solved

Some background: I have a c++ program that is multithreaded using pthreads. The program is a hotel reservation system, with 10 guests (each their own thread), a check-in desk (1 thread) and a chec...
Tsunami asked 16/11, 2014 at 19:20

2

Good day, I wrote a Java program that starts multiple C++ written programs using the Process object and Runtime.exec() function calls. The C++ programs use cout and cin for their input and output....
Cerebrospinal asked 13/6, 2012 at 17:14

6

Solved

I'm creating my own logging utility for my project, I want to create a function like iostream's std::cout, to log to a file and print to the console as well. Here's what i want: enum { debug, er...
Nomination asked 29/1, 2015 at 14:53

5

I want to create a logger class such that with a functionality like this: Logger log; log << "Error: " << value << "seen" << endl; This should print me a custom formatted...
Bedard asked 10/2, 2010 at 9:9

1

Solved

I've got a project that creates a console application, as part of a larger solution, however it won't display anything on the console. I've checked that /SUBSYSTEM:CONSOLE is set for both debug and...
Nairn asked 11/12, 2014 at 16:47

2

Every time I do 'cout << endl' or even 'cout << "\n"' and then launch my program under Windows to output to a file ("a.exe < test.in > result.out") I get "\r\n" line endings in "resu...
Seabury asked 13/4, 2011 at 18:52

5

Solved

I just came across this question which is about how to be able to print an object via std::cout << x << std::endl; As I understood, the standard way to accomplish this is to overload...
Gyroplane asked 3/12, 2014 at 10:36

2

Solved

I just want to format a string and an integer value with right justify. There is no problem to do this without leading space before the integer value. bytes.....................123981 total byte...
Kaceykachina asked 16/11, 2014 at 16:53

5

Solved

Just reading an old but interesting article by "Scott Meyers" http://aristeia.com/Papers/C++ReportColumns/novdec95.pdf Basically it is about preferring to use '\n' over std::endl (which I agree ...
Carrefour asked 17/11, 2014 at 15:19

5

Solved

I can't figure out why this isn't working... I am working in Linux. g++ doesn't do anything. gcc prints the following: /tmp/ccyg7NDd.o: In function `main': test.cc:(.text+0x14): undefined ref...
Sarmiento asked 25/2, 2012 at 19:44

3

I'm developing a c++ program that is dealing with addresses for different variables and functions. When I compiled my program on a Linux based OS, all functions including the main get the address o...
Geezer asked 28/8, 2014 at 0:1

4

Solved

I need to: Set precision so that floats are rounded to the hundredths place ( 0.111 prints as 0.11 ) Clip trailing zeros ( 1.0 prints as 1 ) Never print an exponent ( 1000.1 prints as 1000.1 ) ...
Selmore asked 20/8, 2014 at 11:38

11

Solved

I am writing a program that uses prints a hex dump of its input. However, I'm running into problems when newlines, tabs, etc are passed in and destroying my output formatting. How can I use printf...
Betimes asked 3/7, 2009 at 15:2

6

Solved

I'd like to overload << operator to write the value it takes to a file and cout. I have tried to do it with following code, but couldn't succeed it. It just writes the value to text file. Any...
Necktie asked 25/6, 2014 at 16:13

2

I want to print a large message in c++ using cout. example: cout<<"Camera could not be opened in the requested access mode, because another application (possibly on another host) is using ...
Diplomat asked 4/4, 2014 at 22:52

2

Solved

I am printing progress of many iterations of a computation and the output is actually the slowest part of it, but only if I use Visual C++ compiler, MinGW works fine on the same system. Consider f...
Beforetime asked 25/3, 2014 at 11:48

3

Solved

How do I make std::cout << 123456789.12 print this: 123456789.12 It always prints this: 1.23457e+008 I know that I have to play with the flags, but I cant quite figure out the right...
Pigeonhole asked 13/3, 2014 at 15:25

1

Solved

I know endl or calling flush() will flush it. I also know that when you call cin after cout, it flushes too. And also when the program exit. Are there other situations that cout flushes? I just wr...
Aggri asked 12/3, 2014 at 7:56

2

Solved

I have code such as the following: std::cout << "Beginning computations..."; // output 1 computations(); std::cout << " done!\n"; // output 2 The problem, however, is that often outp...
Gantt asked 25/2, 2014 at 21:35

3

Solved

Say I have a dword I want to output in hex with std::cout and left-pad with zeros, so 0xabcd will be shown as 0x0000abcd. It seems like you would have to do this: uint32_t my_int = 0xabcd; ...
Teresitateressa asked 28/1, 2014 at 20:43

5

Solved

Latelly I've been working with multi-thread coding, after a while writing I realized that if I used std::cout in different boost::threads, the output would came without a logical order, the program...
Arequipa asked 17/2, 2012 at 16:51

© 2022 - 2024 — McMap. All rights reserved.