|
-
April 18th, 2010, 09:00 PM
#1
Seg Fault When Debugging
My program is rather extensive, however, whenever I go to debug my main function which utilizes my main class (which in turn uses various other classes) I get a seg fault wherever I put the break point. Here's my main file.
Code:
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
#include "CheckIn.h"
#include "Customers.h"
using namespace std;
int main()
{
ifstream infile;
infile.open("in.txt");
CheckIn Hotel;
if (infile.fail())
{
cout << "Cannot open file, program terminated." << endl;
exit(1);
}
string lineread; //holds a line from the input file
while(getline(infile, lineread))
{
string sub; //holds the individual words within lineread
istringstream iss(lineread);
while (iss >> sub)
{
if (sub == "add")
{
Customer person;
string tempfirst, templast, temptype;
int tempnights;
iss >> tempfirst >> templast >> temptype >> tempnights;
Hotel.add(tempfirst, templast, temptype, tempnights);
}
}
}
//used for testing purposes
cout << Hotel.Platinum.CustArray[0].firstname << endl;
cout << Hotel.NonElite.backPtr->person.firstname << endl;
return 0;
}
Basically, wherever I put a break point, while debugging the file, I get a seg fault. However, that said I can run the program and it doesn't crash, so I am a bit confused at this behavior. If needed I can post my entire code. I am wondering if anyone knows of something within C++ that could cause this kind of behavior. Thanks, and let me know if you want my entire code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|