Possible Duplicate:
Practical use of extra braces in C
Unnecessary curly braces in C++?
What is the usage of the braces, for example as shown below:
int var;
{
some coding...
...
}
there is no function name before the braces, nor typedef, etc.
Updated:
i found this code in gwan sqlite.c example, http://gwan.com/source/sqlite.c
i partially quote it below:
...some coding
sqlite3_busy_timeout(db, 2 * 1000); // limit the joy
// -------------------------------------------------------------------------
// create the db schema and add records
// -------------------------------------------------------------------------
{ //<-- here is the starting brace
static char *TableDef[]=
{
"CREATE TABLE toons (id int primary key,"
"stamp int default current_timestamp,"
"rate int,"
"name text not null collate nocase unique,"
"photo blob);",
// you can add other SQL statements here, to add tables or records
NULL
};
sqlite3_exec(db, "BEGIN EXCLUSIVE", 0, 0, 0);
int i = 0;
do
{
if(sql_Exec(argv, db, TableDef[i]))
{
sqlite3_close(db);
return 503;
}
}
while(TableDef[++i]);
// add some records to the newly created table
sql_Exec(argv, db,
"INSERT INTO toons(rate,name) VALUES(4,'Tom'); "
"INSERT INTO toons(rate,name) VALUES(2,'Jerry'); "
"INSERT INTO toons(rate,name) VALUES(6,'Bugs Bunny'); "
"INSERT INTO toons(rate,name) VALUES(4,'Elmer Fudd'); "
"INSERT INTO toons(rate,name) VALUES(5,'Road Runner'); "
"INSERT INTO toons(rate,name) VALUES(9,'Coyote');");
sqlite3_exec(db, "COMMIT", 0, 0, 0);
// not really useful, just to illustrate how to use it
xbuf_cat(reply, "<br><h2>SELECT COUNT(*) FROM toons (HTML Format):</h2>");
sql_Query(argv, db, reply, &fmt_html, "SELECT COUNT(*) FROM toons;", 0);
} //<-- here is the ending brace
...some coding