64 735
Assignments Done
99,3%
Successfully Done
In September 2018

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;
else
if(!strcmp(profession, index))
cout << "second letter" << endl;
else
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&nbsp;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!

Comments

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!

ragmar
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

Submit
Privacy policy Terms and Conditions