november fest

//this code works on my turbo c++ but its showing compilation errors in gcc(4.8.1)

#include<stdio.h>
#include<conio.h>
#include<string.h>
int pallindrome(char str[]) ;
void main()
{int k,i,n,j,t,flag=0;
char str[100],str1[100];
clrscr();
printf(“enter T”);
scanf("%d",&t);

for(k=0;k<(t+1);k++)
{
gets(str);
strcpy(str1,str);
n=strlen(str);
for(i=1;i<=n;i++)
{
for(j=i-1;j<n;j++)
str[j]=str[j+1];
flag=pallindrome(str);
if(flag==1)
{
printf(“yes”);
break;
}
strcpy(str,str1);

}
if(flag==0)
printf(“no”);
}
getch();
}
int pallindrome(char str[])
{
char str1[100];
strcpy(str1,str);
strrev(str1);
if(strcmp(str,str1)==0)
return 1;
else
return 0;

}

conio.h header is not defined in gcc compilers. So you should avoid using this header and its functions while submitting your solution.

2 Likes