No thing in the screen typed

i have this a part only of a hole program
i read from a file and i cout it no thing typed in the screen
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
#include <iostream>
#include <fstream>
#include <string>

using namespace std;
ofstream outfile;
int FindProduct(string);
void CustomerBill();

int main()
{
	ifstream infile1;
	ofstream outfile;
	string name,BarCode;

	infile1.open("CustomerFile.txt");
	outfile.open("Bills.txt");

	infile1 >> name >> BarCode;

	while ( infile1 )
	{
		FindProduct(BarCode);

		infile1 >> BarCode;
	}
	infile1.close();
	outfile.close();

	return 0;
}

int FindProduct(string BarCode)
{
	ifstream infile2;
	int Q;
	string BarCode2;
	
	infile2.open("StoreFile.txt");

	infile2 >> BarCode2 >> Q;

	while ( infile2 )
	{
		if ( BarCode == BarCode2 )
			cout << BarCode2 << " " << Q;

		infile2 >> BarCode2 >> Q;
	}
	infile2.close();

	return 0;
}
Last edited on
code tag indent please
what do u mean?
i don't understand......!!!
do you mean like this?

good note..
hi oman,

I read your code, I think maybe you should add some test strings in your "CustomerFile.txt" and "StoreFile.txt". I do not know why do you use Bills.txt.
my example:
try to add strings to files.
====
CustomerFile.txt should include following sting:
====
number
1
2
3
4
5
6
7
8
9
10
11
12
13
14

====

StoreFile.txt should include following:
====
1 20100201
2 20100202
3 20100203
4 20100204
5 20100205
6 20100206
7 20100207
8 20100208
9 20100209
10 20100210
11 20100211
12 20100212
13 20100213
14 20100214
15 20100215
16 20100216
17 20100217
18 20100218
19 20100219
20 20100220
21 20100221
22 20100222
23 20100223
24 20100224
25 20100225
26 20100226
27 20100227
28 20100228
29 20100229
30 20100230
31 20100231
32 20100232
33 20100233
====

compile your app and run it. I think you could see the following:

1  20100201
2  20100202
3  20100203
4  20100204
5  20100205
6  20100206
7  20100207
8  20100208
9  20100209
10  20100210
11  20100211
12  20100212
13  20100213
14  20100214

I add "endl:" in cout sentence.
Last edited on
i have already string in the both files but no way it does not print any thing in the screen
thank you Zhuge and bolo for your comment
Topic archived. No new replies allowed.