大括号的用途是什么,例如下图:
int var;
{
some coding...
...
}
大括号之前没有函数名,也没有 typedef 等。
更新:我在 gwan sqlite.c 示例中找到了这段代码, http
://gwan.com/source/sqlite.c
我在下面部分引用了它:
...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