开发者

undefined reference to stricmp

I am trying to create a method that finds and replaces a string within a string but I seem to have some error at compile time with it. Could I get some help into figuring out what is going on?

void replaceString(char *find, char *replace)
{
    int len_string,i;
    char temp[30];
    len_string=strlen(find);
    while(1)
    {
        for(i=0;i<len开发者_开发问答_string;i++) temp[i]=fgetc(edit);
            temp[i+1]=NULL;
        /* the stricmp() is used for comparing both string. */
        if(stricmp(find,temp)==0)
        {
            fprintf(edit,"%s ",replace);
            fclose(edit);
            exit(1);
        }
        fseek(edit,-(len_string-1),1);
    }       
}

the error I get at compile time is undefined reference to stricmp. I know it isn't proper coding convention, but edit (object of type FILE) is currently a global variable.


stricmp is Windows-specific. If you're not on Windows, strcasecmp.


Actually, the error is at link time and NOT at compile time. Your code got compiled to an object file expecting to find implementation of stricmp while linking with other object files which it couldn't find. Hence the error: "undefined reference to stricmp". As bmargulies pointed out, the implementation is available in only on Windows libraries. You can switch to strcasecmp() if you are on POSIX compliant systems.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜