File io help

Started by
2 comments, last by Zahlman 18 years, 1 month ago

ifstream fin;
fin.open(settings);
fin >> entry.left >> entry.right >> entry.top >> entry.bottom;
fin >> text.left >> text.right >> text.top >> text.bottom;
fin >> drag.left >> drag.right >> drag.top >> drag.bottom;
fin.close();
		
fin.open("ConsolCommands.txt");
int a = 0;
fin >> a;
fin.close();


The first part works fine but then I open ConsolCommands.txt and try to input the first int a always always stays equal to zero. Any help would be great thanks!
Advertisement
Try adding fin.clear() after the first fin.close() to clear a possible EOF flag.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
That did it. Thanks.
You could also just use a different ifstream object :)

This topic is closed to new replies.

Advertisement