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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With