76 361
Assignments Done
Successfully Done
In May 2019

Answer to Question #43348 in C++ for ragmar

Question #43348
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;
if(!strcmp(profession, index))
cout << "second letter" << endl;
if(!strcmp(subject, index))
cout << "third letter" << endl;
Expert's answer
strcmp function returns 0 if the strings are equal. Computer &quot;thinks&quot; that everything that is not zero is true, and zero is false.
So the line which confused you is read as &quot;if not strcmp(name, index) equals true&quot; or &quot;if(strcmp(profession, index) == 0)&quot;

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!


Assignment Expert
26.06.14, 16:11

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!

17.06.14, 09:43

thank u very much really thank you keep in touch who ever you are!!!!!!!
very much appreciated.

Leave a comment

Ask Your question

Privacy policy Terms and Conditions