When studying arrays I got a problem.
I'd appreciate if you help me to get output for this code.
I need to
- inverse array in new array
- compare both arrays to check whether input is a palindrome or not
- without using string.h library
# include<stdio.h>
int main(void)
{
char pal[15],palcpy[15];
int slen,i,j;
printf("\t\tpalindrome checker :)\n\nplease input the word you need to check : ");
scanf("%s", pal);
slen = strlen(pal);
for(i=slen ; i>=0 ; i--)
{
for(j=0 ; j<=slen ; j )
{
palcpy[j] = pal[i];
}
}
printf("%s", pal);
return 0;
}
CodePudding user response:
In line with https://ericlippert.com/2014/03/21/find-a-simpler-problem/ ( and How do I ask and answer homework questions? ) I recommend:
- Start with a HelloWorld, test
- Extend to read a string and echo, test
- Extend to copy the string to a second array, test
- Modify to echo from copy, test
- Extend to verify that original and copy are identical, test
- Modify to copy in reverse, test