How can we compare string inside if statement. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can we compare string inside if statement.

I want to print "hello" in the code when char a="Eath " please help me in this code . https://code.sololearn.com/cCDLCnFlz28P/?ref=app

20th Nov 2018, 2:31 PM
Anish Poudel
Anish Poudel - avatar
2 Answers
+ 9
You need to use strcmp function to compare two strings. You need to use cstring library for that function. This function will return 0 if both strings are equal.
20th Nov 2018, 4:43 PM
blACk sh4d0w
blACk sh4d0w - avatar