C function defined as int but having no return statement in the body still compiles

后端 未结 7 2159
走了就别回头了
走了就别回头了 2020-11-28 13:48

Say you have a C code like this:

#include 

int main(){
    printf("Hello, world!\\n");
    printf("%d\\n", f());    
}

in         


        
7条回答
  •  醉话见心
    2020-11-28 14:04

    You probably have the warning level of your compiler set very low. So it is allowed, even if the result is undefined.

提交回复
热议问题