не забудьте увеличить два указателя.

ужно сделать, это прочитать входной файл в связанный список. Часть файла:

Имя А, 25
NameB, 33
NameC, 23
NameD, 39

А после мне нужно отсортировать по номеру (пузырьковая сортировка) и записать его в другой файл.

Вот что у меня есть:

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

struct node{
    char name[20];
    int number;
    struct node *next;
    struct node *prev;
}*head;

int main(void) {

    struct node *temp;
    temp = malloc(sizeof(struct node));
    temp->next = NULL;
    head = temp;

    FILE *ifp;
    char fnamer[100] = "";
    char line[128];
//    printf("\n\nPlease Enter the Full Path of the file: \n");
//    scanf("%s",&fnamer);

    ifp = fopen("mintaadatok.txt", "r");
    if (ifp == NULL) {
        printf("\n%s\" File NOT FOUND!", fnamer);
        exit(1);
    }

    int c = 0;

    char buffer[1024];
    memset(buffer, 0, 1024);
    while (c < 15) {
        fgets(buffer, 1024, ifp);
        sscanf(buffer, "%19[^,], %d", temp->name, &temp->number);
        printf("%d %s %d\n", c, temp->name, temp->number);
        temp->next = malloc(sizeof(struct node));
        temp = temp->next;
        temp->next = NULL;
        c++;
    }

    int i,step;
    for (temp = head; temp; temp = temp->next) {
        printf("%s", temp->name);
        printf("%d\n", temp->number);
        for(step=0;step<10-1;++step)
            for(i=0;i<10-step-1;++i)
            {
                temp->next = malloc(sizeof(struct node));
                if(temp->number>temp->next)
                {
                    temp=temp->number;
                    temp->number=temp->next;
                    temp->next=temp;
                }
            }
    }
    printf("In ascending order: ");
}

Можете ли вы помочь мне отсортировать эти данные?

Ответы на вопрос(3)

Ваш ответ на вопрос