开发者

why I get error: 'strcmp': identifier not found (visual studio 2010)

开发者 https://www.devze.com 2023-01-15 20:07 出处:网络
why do i get error: \'strcmp\': i开发者_开发问答dentifier not found in visual studio 2010 C++ Express

why do i get error: 'strcmp': i开发者_开发问答dentifier not found in visual studio 2010 C++ Express

#include <string.h>
#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
    printf("%d",(int)strcmp( "str1", "str2" ));

    return 0;
}

Thanks


:( #include <string.h> :(
#include "stdafx.h"

Fun quirk of the MSVC compiler, it generates the exact same error when you compile it like that. Yes, not a lot of 'fun'. It skips everything to find the stdafx.h precompiled header include directive. The string.h doesn't actually get included. Fix:

#include "stdafx.h"
#include <string.h>

Always put the stdafx.h include first.

0

精彩评论

暂无评论...
验证码 换一张
取 消