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;
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)"
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++