problems when reading from a text file

im trying to learn about the fstream in c++
and so i tried to make a program that read from and printed it out on the console
but something very wired happened..

so i have these two files:
testy.txt
&
db.txt


the testy.txt is one that i made myself and all it contains is:
1
2
3
this is a test
this is another
this is a third


the db.txt is one i got of the internet so that i had something to run my program on and all it contains is database information like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
('RWIN', 'b64a850dedf106fdf6c11f09e6369d52', 'rpw16@live.nl', '', '87.195.246.56'),
('brentje', '6ebe76c9fb411be97b3b0d48b791a7c9', 'brent2004@live.com', '', '212.187.55.190'),
('Joe', '9e272443ac7e33396caeb85e66905063', 'tenge@live.nl', '', '84.85.66.148'),
('addiqtion', '1cec8fdbb8c7c692506e5de9583f4e6d', 'lionel_erdem@live.nl', '', '62.194.230.160'),
('sopii', '79f747587ceec343255259d0db205e27', 'lemsophaedra_123@hotmail.com', '', '91.177.248.202'),
('xStaffoo', '8dcc40b95fe974eb173911b31b9a5cec', 'dominiquegabana@live.com', '', '77.167.99.251'),
('Sulake', '3999b28533238e774e64d798b2427521', 'Gaatjeniksaan@live.nl', '', '81.70.208.117'),
('Enrique', '90aec66aa0139675c668e3557e08916d', 'enriquetjuh@live.nl', '826dabf6e74e583ffbfccb2c7cab747d', '94.215.1.129'),
('Thom', '724d353ecfc545e1a6c021d65a0e3b43', 'hv16@live.nl', '', '82.72.94.243'),
('darksz', '78b4e7cdea474e2d0958062b2b3a4b4f', 'darksz@live.nl', '', '143.176.17.115'),
('Murat', 'fc59c8f20afefd56d0d9e5395c7cda64', 'murat_01_88@hotmail.com', '', '77.167.165.149'),
('PHOENiX.', '1a850d3f283c01002dd2d075d2518ff7', 'coenreekers@hotmail.com', '', '82.72.94.243'),
...



and now heres my program:
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
#include <iostream>
#include <fstream>


using namespace std;

int main()
{
	

	ifstream iFile("testy.txt");

	if (!iFile.is_open())
		return -1;

	
	const int buffer = 10000;
	char line[buffer];
	

	while(iFile.getline(line, sizeof(line) / sizeof(char)))
		cout << line << endl;


	char temp;
	cin >> temp;

	
	
	return 0;
}


when i run it with the testy.txt file i get:
this is a test
this is another
this is a third
,as expected.

but when i run it with the db.txt something really wired happens and i just get a blank screen?

and on my console the scrollbar has rolled all the way down, as if its just put a bunch of blankspace instead of the file content?

why is this happening?
Last edited on
Topic archived. No new replies allowed.