I didn't want to do this, but I have found where my code is hanging. I figured it would be easier for you guys to see what I mean. I have made a couple of small changes to the main loop.
Code:
ifstream inFile; // Used to open the logs.
ofstream outFile; // Used to make output.
char start[7]; // Holds the start date (YYMMDD).
char end[7]; // Holds the end date (YYMMDD).
char curr[7]; // Holds the current date. (YYMMDD).
char fName[13]; // Holds the file name to open.
char line[15]; // Start of line.
char name[256]; // For holding a name.
char ch; // Holds an idividual character from the file.
int test; // TEST VARIABLE.
int check[2]; // For checking for values.
int type; // For Message or PHONEMAIL formatting differences.
strcpy(curr, "080310"); /* TEST CODE - NEEDS TO BE REMOVED LATER */
strcpy(fName, "mr"); // Add 'mr' to the filename.
strcat(fName, curr); // Add the current date to the filename.
strcat(fName, ".log"); // Add the extension to the filename.
// Open the input and output file and do error checking.
inFile.open(fName);
outFile.open("LogReport.txt");
inFile.get(ch);
while (!inFile.eof())
{
// Get the beginning of a line and see how to process it.
inFile.get(line, 14);
type = 0;
if (line[12] == 'M')
{
type = 1;
}
// Process as Message line.
if (type == 1)
{
// These first two while loops find the characters that delimit where
// a name is going to be located.
check[0] = 0;
while (!check[0])
{
inFile.get(ch);
if (ch == '(')
{
check[0] = 1;
}
cout << "stuck?" << endl;
cout << ch << endl;
}
check[1] = 0;
while (!check[1])
{
inFile.get(ch);
if (ch == '/')
{
check[1] = 1;
}
}
inFile.get(name, 256, ')'); // Pickup the name.
outFile << name << endl; // Output the name.
// Find the end of the current line.
inFile.get(ch);
while (ch != '\n')
{
inFile.get(ch);
}
}
// Process as PHONEMAIL line
else
{
// The current line is PHONEMAIL.
cout << "PHONEMAIL - Process me!" << endl;
return 0;
}
inFile.get(ch); // Get the next input.
cout << ch << endl;
}
The bold loop is where my code gets stuck. I have poured over this and I can't seem to find what is wrong. I have a feeling that this is from something stupid that I am doing.
Thanks for all the help!