Мне интересно, возможно ли преобразовать строки в связанный список, например "hello \ nhi \ nhey \ n \ 0", в hello -> hi -> hey -> NULL, где каждый узел является строкой.
Пока здесь мой код, и я не уверен, как превратить его в связанный список.Пожалуйста, скажите мне, если я иду в правильном направлении.Спасибо
typedef struct node{
char *text;
struct node *prev;
struct node *curr;
struct node *next;
} Node;
Node newNode(char text[]) {
struct Node *Line = malloc(sizeof(struct Node));
assert(Line != NULL);
int lineCount = 0;
int lineLength = strlen(text);
int i = 0;
while(i < lineLenght) {
if(text[i] == '\n') {
lineCount++;
// do i need to add more?????
}
i++;
}
// i'm not sure what i should do here....
return newNode;
}