C strings

Can anyone help me? Can I assign string in C? on C++ it works like this,
string name = "david";
if(name == "david"){ cout << "it will print" << endl; }
and in C it doesn't work why?
char name[25];
strcpy(name,"david");
if(name == "david"){printf("it doesn'y work") }
Why don't print, when I assigned string? : )

name == "david" name decays to char*, "david" has type const char* — you are comparing two pointers here which doesn't make sense in current context. Use strcmp() function instead
Thank you :)
Topic archived. No new replies allowed.