I just installed Dev C++, its been a couple of years since I've programmed in C++, but I am not really a beginner. I am trying to do a simple read in from a txt file and for whatever reason my executable hangs at the while loop. It doesn't even seem to enter the while loop. I cut the code down to show my problem. I changed the loop to be infinite, but it still doesn't cout lineNum (which is declared above main). lineNum couts fine above the while loop. I have tried deleting the make files etc with no luck.
// Main Function:
int main()
{
cout << "In order to set up a backup please edit the \"backup.txt\" file" << endl;
cout << "and ensure that this file is in the same directory as this program" << endl;
ifstream backFile ("backup.txt");
if (backFile.is_open())
{
cout << lineNum;
while ( true );
{
cout << lineNum;
lineNum++;
}
backFile.close();
}
else
{
writeLog (1);
}
system("PAUSE");
return 0;
}
Am I missing something? Kind of stumped, hah. If I comment out that while loop the executable finishes.
As i said in the op lineNum is declared above main. I left out a function I had above as well (writeLog).. I don't want it to be an infinite loop, it is just that way temporarily for troubleshooting.