What is the purpose of anonymous { } blocks in C style languages (C, C++, C#)
Example -
void function() { { int i = 0; i = i + 1; }
They are often useful for RAII purposes, which means that a given resource will be released when the object goes out of scope. For example:
void function() { { std::ofstream out( "file.txt" ); out << "some data\n"; } // You can be sure that "out" is closed here }