Hi.
i'm trying to make it work, i'm sitting already 3 hours and don't really understand where is the problem.
anybody can help with that please?
Code:
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#define MAXLEN 400
int polindrom (char s[]);
int main(void) {
int type;
char isPolindrom [MAXLEN] = {'\0'};
int i;
printf ("enter your polindrom in one line, up to 400 character \n");
for (i = 0; i<MAXLEN - 1 && ((type = getchar())!= EOF); i++) {
if isalpha (type){
if islower (type)
type = toupper (type);
isPolindrom[i] = type;
}
else
i--;
}
if (!(isalpha (type)))
i++;
isPolindrom[i] = '\0';
if (polindrom (isPolindrom))
printf ("your string is polindrom");
else
printf ("your string is not polindrom");
}
int polindrom (char s[])
{
char endCounter;
char startCounter;
int polindrom = 1;
for (endCounter = 0; endCounter !=('\0'); endCounter++) {
}
for (startCounter = 0; endCounter >0; startCounter++, endCounter--) {
if ('s[startCounter]' != 'c[endCounter]')
polindrom = 0;
}
return polindrom;
}
thank you