COUT not working properly

May someone please help me why my COUT are not being shown on the Dos Console. The only message being displayed on console are everything written under
void make_input and void make_output. in the other functions where I have cout, even in my main function the cout is not being displayed. once again, may someone remedy this issue. Will be great help and thanks in advance! :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

#include "stdafx.h"
#include <string>
#include <fstream>
#include <conio.h>
#include <iostream>
using namespace std;


//make a file for input
void make_input(ifstream &fin,string &filename)

{
	cout<<"Input File: ";
	getline(cin,filename);

	//Open the file
	fin.open(filename);
		//if file doesnt open
			if(!fin)
				cout<<"\nFile not open";
}

void make_output(ofstream &fout,string &filename2)
{
	cout<<"\n\tOutput File Name: ";
	getline(cin,filename2);

	//Open the output file
	fout.open(filename2);

}

//input cow in file
void Put_cow(string &findcow, ifstream &in)
{
	getline(in,findcow);
}


void Read_File(string cow, int size, int & counter)
{
	int rightcow=0;
	counter=0;
	for (int i=1;i<=size;i++)
	{
		if (cow[i-1]==')' &&  cow[i]==')')
		{

			counter=counter+rightcow;
		}
		else if (cow[i-1]=='(' && cow[i]=='(')
		
			rightcow=1;
	}
			cout<<counter;

}


int _tmain(int argc, _TCHAR* argv[])
{
	cout<<"Hello";
	//Declare variables for ifstream and ofstream
		ifstream in;
		ofstream out;
		string name_Input_File;
		string name_Output_File;

		string find_cow;
		int length;

	//Call the function to open input file
		make_input(in,name_Input_File);
	//Call funtion to open output file
		make_output(out,name_Output_File);

		//read the file while file is open
		Put_cow(find_cow,in);
		//Find the length of string
		length=find_cow.length();

		//Total posilbity of cow
		int total_Cow=0;
		cout<<"\n\n\t" <<total_Cow;
		//Read_File(find_cow,length,total_Cow);

		
You don't seem to be using a standard C++ compiler, also try placing adding cout.flush(); after every cout statement that does not print when it should.
I'm using visua studio 2010...but just for general knowledge can I please know what flush does in simple terms.

Also that didsolve the problem :)
Lol, I should have said that in first place. Frankly and politely speaking, please don't refer me to the reference page. I'm usually don't get some of the materials posted on those references. Stil a novice learner, so if you don't mind may I know in a simplest manner what exactly it does :)
Simplified explanation:

Output is often "buffered". You can think of a buffer as a bucket that holds data.

When you output something to cout, it doesn't necessarily go directly to the screen. Instead it gets buffered (put in that bucket).

Eventually, once the buffer gets full, the buffer will automatically empty itself and display all its contents on screen.

Or... if you want to manually empty the buffer... you can call 'flush' as mentioned above. Flushing the buffer forces it to empty meaning that all the data you put in the buffer will get forced on screen.
Thank you Disch! Seem to get a better understanding of flush now! :)
Topic archived. No new replies allowed.