while input test

I have a program and need a while loop to check if the program is open. how do I code while file not open repeat cin.
Do I
use while (!infile)
cin >> filename
I have been tought to be careful of negations.
Take a look at http://www.cplusplus.com/reference/iostream/ifstream/is_open/ which has something very close to what you want.
Topic archived. No new replies allowed.