Hello all,
First of all thank you for taking the time to help me, I really appreciate it. I would also like to start by saying I am extremely new to C++ and I am sorry if my code is ugly/inefficient. With that said I will move on to the problem.
I am asking about a very strange error I get while trying to run my code. The error message reads:
"This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information."
Since I made the program I am pretty sure that I am technically supposed to be the support team, so that throws that option out the window.
I have tried opening task manager and checking for a process that is keeping it from running correctly and ensured that all of my Microsoft c++ redistributables(spelled wrong) were up to date but to no avail.
From the research I have done, it seems that the: abort() function is what is causing my problem due to an unhandled exception or something.
From the looks of my code, can anyone determine the problem and maybe guide me in the direction of a solution?
I don't know if it matters but I am running Windows 7 Professional 64 bit on a dell laptop with a 2.7 ghz quad-core intel processer, 16 GB RAM, 750 GB HDD. And I am programing with bloodshed Dev-C++.
Source code from my 3 files:
main "sportData.cpp"
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
|
//brian whitsett
//date: 06/24/14
//lab7
#include <iostream>
#include "sportData.h"
#include "sportDataMethods.cpp"
#include <iomanip>
#include <cmath> // Needed for the pow function
using namespace std;
int main()
{
sportData players[100];//array of objects
char runAgain = ' ';
do
{
sportData sportData;
sportData.execute(players);//call member method
cout << "Enter More Player Stats?[Y|N]: ";
cin >> runAgain;
cin.ignore();
runAgain = toupper(runAgain);
system("pause");
system("cls");
}
while (runAgain == 'Y'); //end of do while
return 0;
}//end of main
/*
*/
|
header: "sportData.h"
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
|
#ifndef sportData_H
#define sportData_H
#include <iostream>
#include <string>
using namespace std;
class sportData//class
{
private:
//private variables
int iceTime;
int goals;
int points;
int penalties;
int assists;
string playerName;
public:
~sportData();//public member methods
sportData();
sportData(int iT, int g, int p, int pen, int a, string n);
void getStats();
void writeStats();
void displayStats();
void execute(sportData players[]);
int errorCode(double testDoubleVariable);
};
#endif
|
member methods: "sportDataMethods.cpp"
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
#include "sportData.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int howMany = 0;
sportData::~sportData()
{
}
sportData::sportData()
{
int iceTime = 0;
int goals = 0;
int points = 0;
int penalties = 0;
int assists = 0;
string playerName = 0;
}
sportData::sportData(int iT, int g, int p, int pen, int a, string n)
{
iceTime = iT;
goals = g;
points = p;
penalties = pen;
assists = a;
playerName = n;
}
void sportData::getStats()//gets data
{
int test = 1;
cout << endl;
cout << "Enter Player Name: " ;
cin.ignore();
getline(cin, playerName);
while ((test == 1) || (iceTime <= -1))//error code
{
cout << "\nEnter Player's Time On Ice: ";
cin >> iceTime;
test = errorCode(iceTime);
}
while ((test == 1) || (goals <= -1))//error code
{
cout << "\nEnter Player's Goals: ";
cin >> goals;
test = errorCode(goals);
}
while ((test == 1) || (points <= -1))//error code
{
cout << "\nEnter Player's Points: ";
cin >> points;
test = errorCode(points);
}
while ((test == 1) || (penalties <= -1))//error code
{
cout << "\nEnter Player's Penalties: ";
cin >> penalties;
test = errorCode(penalties);
}
while ((test == 1) || (assists <= -1))//error code
{
cout << "\nEnter Player's Assists: ";
cin >> assists;
test = errorCode(assists);
}
cout << endl;
}//end func
void sportData::writeStats()//calculates average
{
fstream fs;
fs.open("playerStats.txt", ios::out | ios::app);
fs << playerName << " " << iceTime << " " << goals << " " << points << " " << penalties << " " << assists << endl;
fs.close();
}//end func
void sportData::displayStats()//displays stock data
{
fstream fs;
fs.open("playerStats.txt", ios::in);
while (fs >> playerName >> iceTime >> goals >> points >> penalties >> assists)
{
cout << playerName << " " << iceTime << " " << goals << " " << points << " " << penalties << " " << assists << endl;
}//end while
fs.close();
}//end func
void sportData::execute(sportData players[])//if this assignment was a stir fry, this would be the pot with all the ingrediants in it.
{
int test = 1;
while((test == 1) || (howMany > 100) || (howMany <= 0))
{
cout << "How Many Players Would You Like To Add?: ";
cin >> howMany;
test = errorCode(howMany);
}//end while
for (int i = 0; i < howMany; i++)
{
players[i].getStats();
}//end for
system("pause");
system("cls");
for (int i = 0; i < howMany; i++)
{
players[i].writeStats();
}//end for
for (int i = 0; i < howMany; i++)
{
players[i].displayStats();
}//end for
}//end func
int sportData::errorCode(double testDoubleVariable)//for error coding doubles
{
char errorCh= ' ';
if (cin.fail())
{
cin.clear();
cin >> errorCh;
//if bad
return 1; //1 is bad value need loopback
} //end if
else
{
return 0;//good value
}//end else
}//end func
|
Any answers are appreciated! My class ends tomorrow so I am kind of panicking at this point.
thanks,
-Bryce