Questions tagged [cout]

std::cout is the global stream object provided by the C++ standard library for writing to the standard output stream.

For more general questions about std::ostream use the or tags.

Bjarne Stroustrup, the creator of C++, explains that cout is pronounced "see-out" and the "c" stands for "character". (wcout is used for wide character output to the standard output stream)

1820 questions
0
votes
1 answer

Why does this code compile? cout < "tt";

cout is object of class ostream, and ostream is typedef of basic_ostream: extern ostream cout; typedef basic_ostream ostream; template > class basic_ostream; but none of these classes has…
uchar
  • 2,552
  • 4
  • 29
  • 50
0
votes
3 answers

C++ error: no match for 'operator<<'

Hello I have a problem with this error I cannot understand what's the problem.. So here is full code: #include #include using namespace std; class GradeBook { public: GradeBook(string name) { …
Sangsom
  • 257
  • 6
  • 15
0
votes
3 answers

Overloading Cout Operator When Using Arrays in For Loop? C++

In my random group sorter project, I am receiving an error that I am not sure how to resolve on my own. The code block I'm focusing on for this error: #include #include #include #include #include…
Eitan Myron
  • 159
  • 1
  • 4
  • 16
0
votes
2 answers

C++ setw not aligning columns

I've got an ostream called os that I use like this: os << rec.lastname << " " << rec.firstname << setw(30) << rec.phonenum; And the output is showing up like this: WITT CANDACE 250-939-5404 PERKINS THEODORE …
mshindal
  • 578
  • 6
  • 17
0
votes
1 answer

ostream_iterator to a string instead of cout?

someone just helped me get a filename from a directory with boost using if (exists(p)) // does p actually exist? { if (is_directory(p)) // is p a directory? { copy(directory_iterator(p),…
Aaron
  • 81
  • 2
  • 9
0
votes
0 answers

Using setfill for preceding zeros?

When I run the following program it displays the preceding zeros correctly: #include #include using namespace std; int main() { //Code int num1, num2, num3, num4, num5, num6; cout << "Enter ONE line…
user3281580
  • 53
  • 1
  • 2
  • 5
0
votes
1 answer

Why does a for loop in c++ access a memory location in non-initialized compared to the behavior of a normal cout?

I found this occurrence to be rather interesting, let me explain: When I initialized a int array, I started to wonder how c++ handles an index with a no initialized value. When directly using cout, c++ directly outputs the values as 0. However, when…
RyanH
  • 45
  • 1
  • 7
0
votes
0 answers

Cout to console SDL Code::Blocks

Before you dismiss this as a duplicate I have been searching for a solution for 2 days. I've tried every thing I found except recompiling SDLmain (I don't know how to do this). Anyways I've noticed that many solutions include opening a file ::…
0ctoDragon
  • 541
  • 1
  • 7
  • 20
0
votes
3 answers

Multle ++ statements in single cout

Can someone explain why the following two snippets have different output? int x=0; cout<
Ali Haider
  • 33
  • 4
0
votes
1 answer

Reading in both doubles and words and performing actions based on what is read

I'm writing a program that takes in input and formats it into a score as "Name Score". Here is what needs to be done "Here's Moonglow's format. The text file is composed of words. If a word is a number, then that is a student's score on a question,…
0
votes
4 answers

Turn on/off my own log(cout) prints in c++ - how to do that? any special option?

I use cout and printf for my debugging. However, when i want to run a "clean" code without cout messages i have to comment out every single one. How can i turn on/off example: for(int i = 0 ; i < 10 ; i++){ cout << "======================="…
ERJAN
  • 23,696
  • 23
  • 72
  • 146
0
votes
3 answers

Formatting table - why does '\t' get changed?

I want to format a grid nicely. It is 9x9 grid. I want to delimit it after every 3rd column - put "*" else - '\t'. after every 3rd row put "-------------------------" Horizontal line works nicely - this is easy. But in column 3 it starts printing…
ERJAN
  • 23,696
  • 23
  • 72
  • 146
0
votes
4 answers

operator << overloading in a constructor

I'm debugging a program and I would like to make printing from that pattern: std::cout << firstVar << ", " << secondVar << ", " << thirdVar << endl ; shorter, i.e, the same thing should happen if we will write the code: shortPrint(std::cout) <<…
wannabe programmer
  • 653
  • 1
  • 9
  • 23
0
votes
3 answers

c++ equivalent of this code below (sprintf)

What is the C++ equivalent of the code below? sprintf(name,"jari%d.jpg",rank+42+size); help me how to change it to c++. can anyone help me?
Monic92
  • 21
  • 5
0
votes
1 answer

Total wont print as a double

Im finding the middle position of an array, but if it is an even set of arrays i must find the average of the two middle numbers. i have the variable initialized as a double; but it still wont work. I've tried setprecision and the correct values…
SalehK
  • 61
  • 1
  • 1
  • 6