Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
339 views
in Technique[技术] by (71.8m points)

c - Why are declarations put between func() and {}?

In sed source I saw often

func(...)
int b;
char c;

{
...
}

Why put variables there? Does it change the scope?

Like here: http://www.mirrors.docunext.com/lxr/http/source/src/bin/sed/lib/regex_internal.c?v=haiku

re_string_allocate (pstr, str, len, init_len, trans, icase, dfa)
 51      re_string_t *pstr;
 52      const char *str;
 53      int len, init_len, icase;
 54      RE_TRANSLATE_TYPE trans;
 55      const re_dfa_t *dfa;
 56 {
 57   reg_errcode_t ret;
 58   int init_buf_len;
 59 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is K&R (old) style, it works, but..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...