'Create a linked list with the characters of a string-C90

The problem : I am trying to create a linked list which contains the characters of a string in each field of the linked list(to get the distance of each letter of a word between the first and the second occurrence - that is another part)..But I keep getting 2 errors which I do not really understand them and/or I do not know why they come up...

The errors:

  1. Line 52 - error: assignment to 'Char **' {aka 'struct charact **'} from incompatible pointer type 'Char *' {aka 'struct charact *'} [-Wincompatible-pointer-types]| and

  2. Line 53- error: '*iterator' is a pointer; did you mean to use '->'?|

The code:

#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)
{
    int i = 0;
    ListofChar *iterator = NULL;
    iterator = lst_ptr;

    for(i = 0;  i<strlen(name) ; i++)
    {
        iterator = createnode(name[i]);
        iterator = iterator->next;
    }
    return;
}


void report(ListofChar chars)
{
    ListofChar iterator = NULL;
    for(iterator = chars; iterator!= NULL; iterator = iterator->next)
    {
    printf("\n character : %c   occurs = %d",iterator -> ch, iterator->occurs);
    }

    return;
}

Note that I've recently learned about linked lists in c,so there may be something major that I am missing..



Sources

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

Source: Stack Overflow

Solution Source