My aim is to take two strings and compare there ends if both of them ends with "ing","ed" or there ends do not match.It always says that strings do not match .
#include <stdio.h>
#include <conio.h>
#include <string.h>
int ised(char str[]);
int ising(char str[]);
int main()
{
char str1[30],str2[30];
printf("Enter 1st string:\n");
gets(str1);
printf("Enter 2nd string:\n");
gets(str2);
if((ising(str1))||(ised(str1))||(ising(str2))||(ised(str2)))
{
if(ising(str1)&&ising(str2))
{
printf("Both strings end with ing");
}
else if(ised(str1)&&ised(str2))
{
printf("Both strings end with ed");
}
else
printf("Both strings ending do not match");
}
else
printf("One or both strings do not end with ing or ed.Program Quitting...");
getch();
return 0;
}
int ising(char str[])
{
int len,flag=0;
len=strlen(str);
if (!(strncpy(&str[len-3],"ing",3)))
flag=1;
else
flag=0;
return flag;
}
int ised(char str[])
{
int len,flag=0;
len=strlen(str);
if( !(strncpy(&str[len-2],"ed",2)) )
flag=1;
else
flag=0;
return flag;
}