what do you mean by "if(!strcmp(subject, index))" i get from this segment of code and i didnt get what does the ! really does
char name[ ] = "a";
char profession[ ] = "b";
char subject[ ] = "c";
cout << "please enter a word to search: ";
cin >> index;
if(!strcmp(name, index))
cout << "first letter" <<endl;
else
if(!strcmp(profession, index))
cout << "second letter" << endl;
else
if(!strcmp(subject, index))
cout << "third letter" << endl;
1
Expert's answer
2014-06-16T11:57:30-0400
strcmp function returns 0 if the strings are equal. Computer "thinks" that everything that is not zero is true, and zero is false. So the line which confused you is read as "if not strcmp(name, index) equals true" or "if(strcmp(profession, index) == 0)"
Comments
Dear Ragmar, You're welcome. We are glad to be helpful. If you liked our service please press like-button beside answer field. Thank you!
thank u very much really thank you keep in touch who ever you are!!!!!!! very much appreciated.
Leave a comment