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

Printing a map of a vector of strings

Trying to print a map>, but I keep getting the error: prob2.cc: In function âvoid printMap(const std::map, std::vector > >&)â: prob2.cc:42:36: error: cannot bind…
CChiste
  • 131
  • 1
  • 2
  • 13
0
votes
6 answers

how can I work with the last element of iterations

for(int t(0); t < 10;++t) { cout<
0
votes
2 answers

Cout doesn't print on display (console)

so i have a code that's supposed to find a string of characters in a certain .txt file, if the input is in the file, it says "yey i found it" but when it isnt, its supposed to say "didnt find anything", but it just skips that step and ends. I'm a…
raz
  • 75
  • 2
  • 12
0
votes
1 answer

Peculiar behavior while recursively calling function in C++ and getting two different outputs for the same code with only an extra line with "cout"

#include #include #define MAXX 1000 using namespace std; int number[MAXX], digits=0; int adjust(int i) { if(number[i]<9) { cout<<"i = "<
Shivendra
  • 1,076
  • 2
  • 12
  • 26
0
votes
1 answer

How to send data-flow from std::cout to gnuplot?

I have a project on ubuntu and C++ and somewhere in my code there is a loop that outputs lots of data to standard output (terminal). Among these data there is an error field that I want to see its evolution as the loop iterates. For sake of clarity,…
Pouya
  • 1,266
  • 3
  • 18
  • 44
0
votes
1 answer

cout string and vector in the same line

Whenever I put a string and a vector in the same line, the string becomes empty. In my code I have, string line, s1, s2; vector > binaryvector; ifstream filename(uncompr_filename.c_str()); If I do while(getline(filename,…
mrbubz
  • 427
  • 2
  • 6
  • 20
0
votes
3 answers

Compiler error while trying to print a string variable in C

#include #include #include #include using namespace std; int getComputerChoice(); int getPlayerChoice(); string convertToString(int); int main() { int computerChoice, playerChoice; string choiceOne,…
user2875331
0
votes
1 answer

Strange behaviour from references in an output stream

I have noticed strange behaviour when printing output to a stream. My code loops through a large dataset and, amongst other things, reads a timestamp from each item. The timestamp from the first item is stored so an elapsed time can be calculated.…
Carl
  • 46
  • 5
0
votes
2 answers

ERROR: cout c++ undeclared

I'm learning c++, following example trows "`Enter' undeclared (first use this function) ". I've been reading some questions in this site and it seems it has to do with not declaring functions. But I can't get it to work. Any help will be greatly…
sms
  • 393
  • 6
  • 20
0
votes
0 answers

Displaying a 2D array of chars and an array of ints in parallel

I have a 2D array of characters forming a word that is to be parallel with an array of ints. How can i properly change this code so it prints out the correct numbers of letter with no junk and keeps each int parallel to the char array. Each name in…
0
votes
3 answers

Vector of subsets

I have the next program.How should I use the iterator in main in order to show the subsets that have the sum 0? My program should print: 2 -2 5 -5 # include < iostream > # include < vector > using namespace std; vector < vector < int > >…
user2868657
0
votes
2 answers

output double in cout C++

I have problem with my C++ console app when I tried to output double that calculate from Vector int it show me 0 for (int i = 0; i < max_streak_length; i++) { cout<< "data win streak of " << i << " acheived : " << gamesData[i]; cout<< "…
user474901
0
votes
5 answers

Beginner C++ Receiving Input in Multiple Ways

For an assignment, part of my program requires that I can receive 2 numbers from either a file or have them entered by hand. I can easily get them from a file by doing: int n1,n2; cin>>n1>>n2; That way, a file with contents simply reading something…
user1804208
  • 165
  • 2
  • 4
  • 9
0
votes
2 answers

C++ Recursion Character Printing

Edit: Corrected Code (Thanks for the answers and help!) #include using namespace std; int arr1(const int n,int i, int j){ if(j != 0) { /* if(i == 2*n ){ cout<<"\n"; --j;}*/ if((i <= (n-j) || (i >= (j+n)) && i <2*n)){ …
user2821771
  • 13
  • 1
  • 1
  • 5
0
votes
2 answers

Does cout object remain a single instance, i.e. it never gets copied?

Is cout ever copied implicitly? For example, is the cout object passed to the second overloaded operator in the code below, and the cout object inside its implementation are the same objects or is one a copy of cout? My understanding is that the…
Krypt
  • 55
  • 4