Я пытался закодировать это с помощью указателей, которые мне удалось получить первый для l oop, чтобы работать, но я не могу заставить другой для l oop работать с помощью указателей. Программа будет игнорировать все символы, которые не буквы и используйте указатели вместо целых чисел, чтобы отслеживать позиции в массиве. Мне нужна помощь с указателями, чтобы отслеживать позицию в массиве.
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
#define N 50
int main()
{
int i, j, k =0,*count; char ch, msg[N], msg1[N]; bool flag = true;
char *p;
count = &k;
// Getting user-defined input
printf("Enter a massage: ");
ch = getchar();
while(ch != '\n' || *count == N)
{
msg[(*count)++] = ch;
ch = getchar();
} // end of while loop
// Printing user-defined input
printf("User-defined input: ");
for(p = msg; p < msg+*count; p++)
printf("%c", *p);
printf("\nNumber of characters is %d\n", *count);
// Sanitiazation of the msg array (i.e., removing special characters)
i = 0;
for(j = 0; msg[j]; j++) {
if(isalpha(msg[j]))
msg1[i++] = tolower(msg[j]);
} // end of for loop
// Palindrome test
for(j = 0; msg1[j]; j++) {
if(msg1[j] != msg1[i-j-1]) {
flag = false;
continue;
}
} // end of for loop
// Printing final decision
if(flag)
printf("Palindrome\n");
else
printf("Not palindrome\n");
return 0;
} // end of main