I'm trying to print a linked list of characters, and then later make a function to copy the string onto a new one and then reverse it and print it out. I'm confused as to why this is printing out only integers, and also how to reverse the string. Here is my code:
#include<stdlib.h>
#include<stdio.h>
struct list_el
{
char val;
struct list_el * next;
};
typedef struct list_el item;
int main()
{
item * curr, * head;
int i;
head = NULL;
for(i='i';i>='a';i--)
{
curr = (item *)malloc(sizeof(item));
curr->val = i;
curr->next = head;
head = curr;
}
head = NULL;
while(curr)
{
printf("%d\n", curr->val);
curr = curr->next ;
}
return 0;
}