-
undefined symbol
Im getting an error that says
>Undefined first referenced
> symbol in file
>
>stricmp num.o
when i test my code, but it compiles all ok and exectutes ok. Any ideas why?
This is how ive used it:
Code:
if(stricmp(cmd, word2) == 0)
printf("2\n");
And i have included string.h
??
-
What do you mean by when you test your code? You stated that it compiles and exicutes ok. If you have an error like that it most certaintly would not link ok. Therefore not exicute ok.
-
The root problem is that stricmp() should be strcmp().
The file may well compile as the compiler may assume that stricmp() is a function that is defined in another file. When it comes to linking you get the error you are seeing 'cos the linker can't find the function the compiler assumed it would.
You should not be getting an executable to be able to say it executes ok. Are you sure you are not using an old executable?
-
>>The root problem is that stricmp() should be strcmp().
stricmp is a non-standard case insensitive compare. It is available on some compilers. IMHO, it is better to write your own function to do the same, that way you can keep it portable and won't run into compile troubles like you are now.