memcmp的隐式声明在c99中无效

123*_*123 3 c xcode c99

我正在Xcode 4中创建一个非常基本的C控制台应用程序,我在编译时遇到警告:Implicit declaration of memcmp is invalid in c99.

我对函数的使用正如您所期望的那样:

if(memcmp(buf, block, 0x14) != 0)
{
    fclose(fh);
    printf("invalid file: %s\n", argv[argc-1]);
    return 1;
}
Run Code Online (Sandbox Code Playgroud)

如何使用该功能错误,我该如何解决?

小智 11

你忘了#include <string.h>,其中包含声明memcmp.