简体   繁体   中英

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

why do i get error: 'strcmp': identifier 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM