I have a wondering here. This code I have below is working great except of one thing that doesn´t make sense to me.
I use a while-loop inside a for-loop as seen.
The for-loop is counting from 1-49 and for each count the while-loop will read a .txt file and put some info to a file.
Notice now in my code in the for-loop that I have put "Display this" to a label on my form.
This should be shown for the first count in the foor-loop wich is 1 ?
What happens in this code is that "Display this" will be shown First when the count is ready, wich then is count = 49.
Why is this happening. It should be shown directly and not in the end of the loop ?
HowEver if I put this message box in the same place instead of "Label1" then it will
Display a new messagebox for each count wich meens 49 MessageBoxes
Code:MessageBox::Show("Display this");Code:std::string Line; ofstream MainFile; MainFile.open ("Main.txt"); for (int count= 1; count < (50); count++) { Label1->Text = "Display this"; ifstream File ("DGD.txt"); while ( getline(File, Line, '\n') ) { MainFile << "Hello" << ',' << "Hello2" << '\n'; } }



LinkBack URL
About LinkBacks



