在函数内调用相同的函数。

时间:2022-11-10 16:45:42
#include<stdio.h>
int slogan();
int main()
{
    slogan(slogan());
    return 0;
}
int slogan()
{
    printf("onlyme\n");
}

My doubt is, the slogan function has no argument list in its prototype, then how come it accepts the function call as its argument?

我的疑问是,标语函数在原型中没有参数列表,那么为什么它接受函数调用作为它的参数呢?

3 个解决方案

#1


8  

In c the empty parameter list does not mean function that takes no arguments. It means function with unspecified number of arguments

在c中,空参数列表并不是指不带参数的函数。它意味着函数的参数数目不确定

To declare a function that takes no arguments write :

要声明一个不带参数的函数,请写:

int func(void);

#2


6  

Because in C,

因为在C语言中,

int slogan();

declares a function without saying anything about its arguments. This is not a prototype declaration at all, it's an old-style K&R declaration. The prototype declaration for a function taking to arguments is

声明一个函数而不涉及它的参数。这根本不是一个原型声明,而是一个老式的K&R声明。接受参数的函数的原型声明是

int slogan(void);

The former form exists for backward compability with pre-1989 C, when you couldn't provide argument information in the prototype at all.

前一种形式存在于1989年以前的C中,当您根本无法在原型中提供参数信息时,它用于向后可压性。

#3


0  

Look at First answer here(and second) The first answer will give you an Accurate explanation of a functions declaration

请看这里的第一个答案(和第二个),第一个答案将给出函数声明的准确解释

Section 6.11.6 Function declarators(K&R C)

第6.11.6节职能申报人(K&R C)

The use of function declarators with empty parentheses (not prototype-format parameter type declarators) is an obsolescent feature.

使用带有空圆括号的函数声明器(不是原型格式参数类型声明器)是一种过时的特性。

#1


8  

In c the empty parameter list does not mean function that takes no arguments. It means function with unspecified number of arguments

在c中,空参数列表并不是指不带参数的函数。它意味着函数的参数数目不确定

To declare a function that takes no arguments write :

要声明一个不带参数的函数,请写:

int func(void);

#2


6  

Because in C,

因为在C语言中,

int slogan();

declares a function without saying anything about its arguments. This is not a prototype declaration at all, it's an old-style K&R declaration. The prototype declaration for a function taking to arguments is

声明一个函数而不涉及它的参数。这根本不是一个原型声明,而是一个老式的K&R声明。接受参数的函数的原型声明是

int slogan(void);

The former form exists for backward compability with pre-1989 C, when you couldn't provide argument information in the prototype at all.

前一种形式存在于1989年以前的C中,当您根本无法在原型中提供参数信息时,它用于向后可压性。

#3


0  

Look at First answer here(and second) The first answer will give you an Accurate explanation of a functions declaration

请看这里的第一个答案(和第二个),第一个答案将给出函数声明的准确解释

Section 6.11.6 Function declarators(K&R C)

第6.11.6节职能申报人(K&R C)

The use of function declarators with empty parentheses (not prototype-format parameter type declarators) is an obsolescent feature.

使用带有空圆括号的函数声明器(不是原型格式参数类型声明器)是一种过时的特性。