extra braces inside main
I ran across this code and was wondering what the extra braces are there for?
const int sz = 100; // Buffer size;
ifstream in("Strfile.cpp"); // Read
assure(in, "Strfile.cpp"); // Verify open
ofstream out("Strfile.out"); // Write
int i = 1; // Line counter
// A less-convenient approach for line input:
in.get(); // Throw away next character (\n)
cout << buf << endl; // Must add \n
out << i++ << ": " << buf << endl;
} // Destructors close in & out
It seems very odd to me but compiled fine when i removed the assure function calls. I also removed the ofstream stuff, but i think it would compile with that in there also
They have no purpose in the posted code, other than to potentially prevent all variables declared in there from being used in the code after the last red }.
They just define another scope block. As a result, all variables declared inside that block, exist only until that block ends, then they're gone.