【问题标题】:What does this weird C++ definition mean? [duplicate]这个奇怪的 C++ 定义是什么意思? [复制]
【发布时间】:2013-03-13 14:44:16
【问题描述】:

我的作业代码中有这个奇怪的函数定义,我真的不知道它应该是什么意思。

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

尤其是“char *string;”行,最后的分号是什么。

【问题讨论】:

标签: c function definition kr-c


【解决方案1】:

它是 C 语言中函数的 K&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
}

【讨论】:

    猜你喜欢
    • 2014-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-02
    相关资源
    最近更新 更多