Nasz profesor wymagał od nas sprawdzenia, czy słowo jest palindromem przy użyciu stosów. Za każdym razem, gdy go uruchomię, wystąpił błąd: Unhandled Exception. Access violation
Co robię źle? Jak mogę poprawić mój kod? Mój kod wygląda następująco:Palindroma przy użyciu stosu
typedef struct stack{
char name;
struct stack * next;
}Stack;
void push(Stack**head, char value);
char pop(Stack**head);
int main(){
char word[11];
int i=0;
int lenght = 0;
Stack*head = NULL;
printf("Please type the word: ");
scanf("%s", word);
lenght = strlen(word);
while(word[i]!='\0'){
push(&head, word[i]);
i++;
}
i = 0;
while(pop(&head)==word[i]){
i++;
}
if(i==lenght) printf("The word is a palindrome");
else printf("The word is not a palindrome");
}
pierwszy: użyj '' value' zamiast wartości [i] 'w podpisaniu funkcji. – ruslik