Blank screen with only blinking cursor

Can anyone see why the code below would not print anything to the screen?
donations.txt is a text file with double values each on their own line.

donations.txt looks like this:

232.56
10.89
5.25
92.08
110.60
19.33
38.45
68.73
50.00
22.22​
200.00
5.00
80.50
350.00

What does not make sense to me is that when debugging absolutely nothing prints out, not even the lines that do not rely on anything.

It shows that the output from debug is:

'ConsoleApplication1.exe' (Win32): Loaded 'C:\Users\Public\Documents\Visual Studio 2012\Projects\ConsoleApplication1\Debug\ConsoleApplication1.exe'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110d.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110d.dll'. Symbols loaded.
The thread 0x798 has exited with code -1073741510 (0xc000013a).
The program '[7032] ConsoleApplication1.exe' has exited with code -1073741510 (0xc000013a).


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
89
90
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

double donations_total(int size, double *money)
{
	double total=0;

	for(int x=0; x<size; x++)
	{
		total =  total + money[x];
	}

	return total;
}

vector <double> range_of_donations(int size, double *money)
{
	vector <double> range;
	double min = money[0];
	double max = money[0];

	for(int x=0; x<size; x++)
	{
		if(*(money + x) < min)
		{
			min = *(money + x);
		}else if(*(money + x) > max)
		{
			max = *(money + x);
		}
	}

	range.push_back(min);
	range.push_back(max);

	return range;
}

void main()
{
	int count=0;
	double num;

	ifstream donations;

	donations.open("donations.txt");
	if(!donations)
	{
		cout<<"File error!\n\n";
		exit(0);
	}

	donations>>num;
	while(!donations.eof())
	{
		count = count +1;
		donations>>num;
	}
	donations.close();

	double * money = new double [count];

	donations.open("donations.txt");
	if(!donations)
	{
		cout<<"File error!\n\n";
		exit(0);
	}

	for(int x=0; x<count; x++)
	{
		donations>>num;
		money[x] = num;
	}

	double total = donations_total(count, money);

	vector <double> range = range_of_donations(count, money);

	cout<<"Philippines Tragedy Donations\n\n-----------------------------\n\n";
	cout<<"The total donations received were $"<<total<<".\n";
	cout<<"The range in size of donations was from $"<<range[0]<<" to $"<<range[1]<<".\n\n";

	donations.close();

	system("pause");
}
Last edited on
Works fine for me, post your donations.txt please.

Also make sure your donations.txt is in the same directory as your project.
It should be in the correct place because I added it through Source Files>Add>New Item>Utility>Text File in Visual Studio 2012 and when I looked through the project file it is in the same folder as Source.cpp
Last edited on
It's very odd. When I copy & paste your numbers into a notepad .txt, it doesn't work, but if I manually type them into the notepad, it does work. Also, just so you know you should do a
 
count+=1;

before the while loop
 
while(!donations.eof())



Really not sure why you're having those issues though.
Last edited on
I think the problem is after line 55. I added a random cout statement on 55 and it displayed, but when added after the while loop nothing displays.
Last edited on
Do you mean replace the count = count +1 with count+=1 because it is simpler or moving that statement elsewhere?
I typed the numbers into the txt file like you did instead of copy paste and the program works. Thank you. Maybe someone can tell me why this is?
Last edited on
Topic archived. No new replies allowed.