#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct Node {
    int n;
    Node* next = NULL;
}Node;

Node* startNode = NULL;

void addNode(int x) {
	Node* newNode = (Node*)malloc(sizeof(Node));
	newNode->n = x; 
	newNode->next = NULL;
	
	Node* current = startNode;

    while(current->next != NULL) {
        current = current->next;
    }

    current->next = newNode;
	
}

void insertNode(int idx, int x) {
	Node* newNode = (Node*)malloc(sizeof(Node));
	newNode->n = x; 
	newNode->next = NULL;
	
	Node* selected = startNode;
	for(int i=0; i<idx; i++)
		selected = selected->next;
		
	Node* tmp;
	tmp = selected_>next;
	selected->next
	
}

int main() {
	startNode = (Node*)malloc(sizeof(Node));
	startNode->n = 1;
	startNode->next = NULL;
	
	int input = -1;
	
	while(1) {
		printf("0을 입력하면 입력이 멈춥니다. 자연수를 입력해 주세요.\n");
		scanf("%d", &input);
		if(input == 0) break;
		
		addNode(input);
	}

	Node* current = startNode;
	while(1) {
		printf("%d ", current->n);
		if(current->next != NULL) printf("-> ");
		if(current->next == NULL) break;
		current = current->next;
	}
	
	delete(startNode);
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: