I'm a beginner in developing, so my sensei gave me a task to complete in which I need to enter a couple of strings in linked lists and after I enter print, they need to be printed in the correct order, from the first to last.
Here is what I got:
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h>
    typedef struct Node {
        char data;
        struct Node *next;
    }node;
char createlist(node *pointer, char data[100]) {
    while (pointer->next != NULL) {
        pointer = pointer->next;
    }
    pointer->next = (node*) malloc(sizeof(node));
    pointer = pointer-> next;
    pointer->data = *data;
    pointer->next = NULL;
}
int main() {
    node *first, *temp;
    first = (node*) malloc(sizeof(node));
    temp = first;
    temp->next = NULL;
    printf("Enter the lines\n");
    while (1) {
        char data[100];
        gets(data);
        createlist(first, data);
        if (strcmp(data, "print") == 0)
            printf("%s\n", first->data);
        else if (strcmp(data, "quit") == 0)
            return (0);
    };
}
When I run it I get: Enter the lines: asdfasdf print (null)
Any help would be appreciated since this is my first time using linked lists.
 
     
     
     
    