I have a basic program that compares two strings :
#include <string>
#include <iostream>
using namespace std;
int main (int argc, char *argv[]) {
if(strcmp (argv[0],"./test") != 0) {
cout << "not equal" << endl;
} else {
cout << "equal" << endl;
}
return 0;
}
it compiles with gcc but not with clang :
> clang -o test test_clang.cpp
test_clang.cpp:7:6: error: use of undeclared identifier 'strcmp'
if(strcmp (argv[0],"./test") != 0) {
^
1 error generated.
Why doesn't it compile with clang ?
EDIT: People are getting harsh on stack overflow, up to the point that I am hesitating to post a question. The question above has a simple answer, fine, but is it normal to down-vote questions (twice in the first minute!) because they have a simple, yet non obvious, answer ?
#include <string.h>
(which is also a valid solution). Minimal research would have answered this question. That is why I downvoted it. Trivial questions diminish the value of this site. – Acetify.h
at the end and those without, is a problem that is best solved by reading a book on C++. I think that would be better for you, and I think it would be better for Stack Overflow. Again; I don't mean to be harsh or mean, but Stack Overflow isn't actually suited for everything. – Acetify