Issue with User Input

May 10, 2012 at 2:17am
When this section of code runs, when I enter an integer for the Number of Grades to be dropped it crashes.

void Course::enterGCInfo(int num)
{
GradeCat tempGC;
string tempStr = "";
cout << "Enter Grade Category Name: ";
cin >> tempStr;
tempGC.setGCName(tempStr);
double tempDbl = 0.0;
cout << "Enter Grade Percentage: ";
cin >> tempDbl;
tempGC.setGCPerc(tempDbl);
int tempInt = 0;
cout << "Enter Number of Grades To Drop: ";
cin >> tempInt;
tempGC.setNumToDrop(tempInt);
setGradeCat(num,tempGC);
refresh();
}
May 10, 2012 at 2:20am
Sorry here is the error I get from Visual Studio:

Unhandled exception at 0x004149eb in Grade Tracker.exe: 0xC0000005: Access violation reading location 0x3343f1c8.
May 10, 2012 at 2:55am
refresh();

What is this?
May 10, 2012 at 10:47am
void Semester::refresh()
{
calcTotalCredHrs();
calcGPA();
sortCourses();
}
May 10, 2012 at 10:56am
Unhandled exception at 0x004149eb in Grade Tracker.exe: 0xC0000005: Access violation reading location 0x3343f1c8.

If you want to solve that problem quickly then do the following:

in your visual studio hit F11,
repeat pressing F11 until program chrashes
A small yellow arrow will guide you through that simple process.
keep an eye on that arrow it will show you exactly where the error is.

Hint:
if you think it's to slow then hit F10
F10 will be skipping blocks of code :D
Last edited on May 10, 2012 at 10:58am
May 10, 2012 at 8:03pm
codekiddy not sure how that is supposed to work but all it did was bring me to some header file with code I couldn't even attempt to understand and move back and forth between a few spots in that file for a good 50 F11s or so.
May 11, 2012 at 5:36am
Doh! such an easy mistake, like they always are. The value I was passing to the function wasn't probably initialized so it was trying to put the information into some trash slot in my array.

Thanks for your attempts to help.
Topic archived. No new replies allowed.