标签云

微信群

扫码加入我们

WeChat QR Code


My crystal ball tells me you never prototyped read_double to return double prior to its invoke in main. Therefore your compiler assumes it is a variable-argument function of the form int func(), and you compiler warnings are either too low, or you're ignoring the ensuing "implicit declaration of function returning int" text in your build. That crystal ball also indicates these two functions are in different source files, otherwise the compiler would have complained about "error: conflicting types for ‘read_double’", and your code shouldn't have even compiled.

2018年10月23日52分21秒

Note that C99 says your program is ill-formed because you do not ensure that read_double() is declared or defined before it is used. If your compiler did not complain, you need to find out how to turn on the compilation warnings, or persuade it that C99 is an old standard (C11 is newer; C18 is newest, but is mainly minor corrections to C11 rather than any startlingly new technology). And heed any warnings it does give. If it still doesn't give good warnings, get a better compiler.

2018年10月23日52分21秒