Simple While Loop Not Functioning?

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.

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

// 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.

Thanks guys,
-SunDry
Where is the definition of lineNum? And it is obvious that you have an infinite loop.
Last edited on
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.
WAIT... i'm dumb.. semi colon after while (true) *FACEPALM*... thanks
Topic archived. No new replies allowed.