2013-03-13 38 views
3

我的作業代碼中有這個奇怪的函數定義,我真的不知道它應該是什麼意思。這個奇怪的C++定義是什麼意思?

char * 
sh_single_quote (string) 
char *string; 
{...} 

尤其是「char * string」行,在末尾用分號表示。

+2

舊風格的C函數聲明。 [看這裏。](http://stackoverflow.com/questions/4581586/old-style-c-function-declaration) – yattering 2013-03-13 14:46:53

回答

5

它是K &在C語言中函數的R風格聲明。

在C語言中,你通常會寫一個函數爲:

size_t strlen(const char *str) 
{ 
    //code 
} 

輸入K & [R風格,這將被寫成:

size_t strlen(str) <--- here you write only the param name 
const char *str; <--- here you write the type along with param name! 
{ 
    //code 
}