'Linked lists printing function does not work

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct charact
{
    char ch;
    int occurs;
    struct charact *next;
};
typedef struct charact Char;
typedef Char * ListofChar;
typedef Char * CharNode_ptr;
void letters(char name[50], ListofChar * chars_ptr);
void report(ListofChar chars);
Char * createnode(char ch);
int main(void)
{
    char name[50];
    ListofChar chars = NULL;
    scanf("%49s", name);
    letters(name, &chars);
    report(chars);
    return 0;
}
Char * createnode(char ch)
{
    CharNode_ptr newnode_ptr ;
    newnode_ptr = malloc(sizeof (Char));
    newnode_ptr -> ch = ch;
    newnode_ptr -> occurs = 0;
    newnode_ptr -> next = NULL;
    return newnode_ptr;
}    
void letters(char name[50], ListofChar * lst_ptr)
{
size_t i, j;



for (i=0;i<strlen(name);i++)
{
   (*lst_ptr) = createnode(name[i]);


    for (j=i+1;j<strlen(name);j++)
    {
        if (name[i] == name[j])
        {
            (*lst_ptr)->occurs = j - i;

            break;

        }

    }


    if(i==strlen(name)-1)
    {
        break;
    }
    (*lst_ptr)->next=createnode(name[i+1]);
    printf("%c %d %p\n",chars->ch,chars->occurs,chars->next);

}
chars ->next=NULL;
printf("%c %d %p\n",chars->ch,chars->occurs,chars->next);

return;
}
void report(ListofChar chars)
{

   while(chars !=NULL)
  {
     printf("%c %d \n", chars->ch,chars->occurs);
     chars = chars->next;
     printf("g");
  }

    return;
}

So instead of using the printfs inside the letters function, I want to use the report function to do the same thing. But for some reason it just doest work. Any help would be very useful. (Also the goal is to print the distance of each letter in a string that the user gave from it's next appearance)

c


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source