+ 1

help..me..

Char a [4] = "pen"; Char input [8]; Puts ("Guess my name. \ N"); Printf ("1.I am a lot of people around. \ N"); Printf ("2.I can draw letters and pictures. \ N"); Printf ("answer:"); Scanf ("% s", input); If (input == a); Printf ("corect answer"); If (input! = A); Printf ("It is not corect answer"); If (input! = A); Printf ("It is not corect answer"); If you enter the correct answer here, this sentence will not print. How do you fix it? You can not do an else statement.

17th Jun 2017, 11:29 AM
2815 minwoo
2815 minwoo - avatar
2 Answers
+ 26
use string function for comparing two strings i.e., if(strcmp(a,input)==0) printf("Correct"); if(strcmp(a,input)!=0) printf("It is not correct answer"); for using this function use string.h library
17th Jun 2017, 12:08 PM
Mansi Dagla
Mansi Dagla - avatar
+ 1
thank you
17th Jun 2017, 12:33 PM
2815 minwoo
2815 minwoo - avatar