Questions about C Function Prototypes and Compilation

后端 未结 4 1796
别那么骄傲
别那么骄傲 2020-12-19 11:37

With the following code:

int main(){
    printf(\"%f\\n\",multiply(2));
    return 0;
}

float multiply(float n){
    return n * 2;
}

When

4条回答
  •  暖寄归人
    2020-12-19 11:58

    An unspecified function has a return type of int (that's why you get the warning, the compiler thinks it returns an integer) and an unknown number of unspecified arguments.

    If you break up your project in multiple files, just declare a function prototype before you call the functions from the other files, and all will work fine.

提交回复
热议问题