Ich versuche, linear verknüpfte Liste rekursiv mit c-Sprache, erstellen, aber halten Sie hier und der Code funktioniert nicht mit dem Fehler "Linker Tools Error LNK2019". Leider kann ich nicht verstehen, was los ist. Hier ist mein Code.Erstellen und Anzeigen von linearen verketteten Liste in C (rekursiv)
Vielen Dank für Ihre große Hilfe im Voraus.
#include <stdio.h>
#include <stdlib.h>
struct node
{
char num; //Data of the node
struct node *nextptr; //Address of the next node
};
typedef struct node element;
typedef element *link;
link head;
void displayList(); // function to display the list
int main()
{
char s[] = "abc";
link stol(s);
{
link head;
if (s[0] == '\0')return(NULL);
else {
head = (link)malloc(sizeof(element));
head->num = s[0];
head->nextptr = stol(s + 1);
return(head);
}
}
printf("\n\n Linked List : To create and display Singly Linked List :\n");
printf("-------------------------------------------------------------\n");
displayList();
return 0;
}
void displayList()
{
link tmp;
if (head == NULL)
{
printf(" List is empty.");
}
else
{
tmp = head;
while (tmp != NULL)
{
printf(" Data = %d\n", tmp->num); // prints the data of current node
tmp = tmp->nextptr; // advances the position of current node
}
}
}
Definieren Sie 'stol'-Funktion außerhalb (und vor)' Haupt'-Funktion. – BLUEPIXY
Danke. Meinst du ich muss "Link stol" außerhalb (und vor) Hauptfunktion setzen? –
Ich meine wie [dies] (http://ideone.com/IHPo0I) – BLUEPIXY