Thread: C Linked lists in linked lists

  1. #1
    Registered User
    Join Date
    Nov 2021
    Posts
    11

    C Linked lists in linked lists

    Code:
    typedef struct innode
    {
        char letter;
        struct innode* next;
    } InnerNode;
    
    
    typedef struct node
    {
        InnerNode* word;
        struct node* next;
    } Node; 
    
    
    
    struct node* append(struct node* head)
        {
            char input[21];
            printf("Enter Word: ");
            scanf("%20s", &input);
            Node* word = NULL;
           // struct node* outernode = malloc(sizeof(struct node));
    
    
            struct innode* newLetter = malloc(sizeof(struct innode));
            struct innode* curr = newLetter;
            for(int i = 0; i < strlen(input); ++i)
            {
                curr->letter = input[i];
                if(i+1 < strlen(input))
            {
                curr->next = malloc(sizeof(struct innode));
                    curr = curr->next;
                }
            }
            word->next = NULL;
    
    
        };

    Ich muss jetzt eine outernode erstellen und den ersten letter an diesen anhängen. wie mach ich das?

  2. #2
    Registered User
    Join Date
    Sep 2020
    Posts
    150
    Quote Originally Posted by awox View Post
    Ich muss jetzt eine outernode erstellen und den ersten letter an diesen anhängen. wie mach ich das?
    Much better to ask in English. Not many people here understand German.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Arrays, Linked Lists and Unordered Lists
    By bob432 in forum C++ Programming
    Replies: 4
    Last Post: 02-03-2020, 04:01 AM
  2. Double Linked Dynamic Lists Vs Unrolled Linked Lists
    By lantzvillian in forum C Programming
    Replies: 6
    Last Post: 02-14-2012, 01:07 PM
  3. Replies: 4
    Last Post: 05-01-2010, 10:19 PM
  4. Question about Linked lists of lists
    By hear_no_evil in forum C Programming
    Replies: 2
    Last Post: 11-08-2004, 02:49 AM
  5. question on linked lists(stack with linked lists)
    By dionys in forum C Programming
    Replies: 1
    Last Post: 06-02-2004, 11:08 AM

Tags for this Thread