Skip to main content

Define a macro EQUALSTR which accepts two strings and compare equality of both string

Define a macro EQUALSTR which accepts two strings and compare equality of both string

#include<stdio.h> 
#include<string.h> 
#define EQUALSTR(str1,str2) strcmp(str1,str2)?0:1 
void main() 
char str1[10],str2[10]; 
printf("\n Enter the two strings: "); 
gets(str1); 
gets(str2); 
if(EQUALSTR(str1,str2)) 
printf("\n Strings are equal"); 
else 
printf("\n Strings are not equal"); 
}

Comments