⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 This is a safe double linked list data structure in order to store data on void* pointer for data se
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include "circular_dlist.h"#define LINE_LENGTH 64int m;int main(int argc, char** argv){    FILE *fp = NULL;    char line[LINE_LENGTH], event;    int id, type;    CreateNew_dl(-1,5);    /* Check command line arguments */    if( argc < 3 )    {        printf("\n Usage: %s <m> <input-file>\n", argv[0]);        return(EXIT_FAILURE);    }    /* Read the m parameter */    m = atoi(argv[1]);    /* Open input file */    if( ( fp = fopen(argv[2], "r") ) == NULL )    {        printf("\n Could not open file: %s\n", argv[2]);        return(EXIT_FAILURE);    }    /* Read input file line-by-line and handle the events */    while( fgets(line, LINE_LENGTH, fp) != NULL )    {        /* Uncomment the line below when in debug mode */        /* printf("\n Event: %s ", line); */        switch(line[0])        {            /* Join event */            case 'J':                sscanf(line, "%c %d", &event, &id);                /* id: the id of the node to be inserted */                Insert_dl(id);                /* your code... */                break;            /* Leave event */            case 'L':                sscanf(line, "%c %d", &event, &id);                /* id: the id of the node to be deleted  */		Delete_dl(id);                /* your code... */                break;            /* Insert event */            case 'I':                sscanf(line, "%c %d %d", &event, &id, &type);                /* id: the id of the file, type: the type of the file to be inserted */		Insert_File(id,type);                /* your code... */                break;            /* Delete event */            case 'D':                sscanf(line, "%c %d", &event, &id);                /* id: the id of the file, to be deleted */		Delete_File(id);                /* your code... */                break;            /* Find event */            case 'F':                sscanf(line, "%c %d", &event, &id);                /* id: the id of the file, to be searched for */		Find_File(id);                /* your code... */                break;            /* Print event */            case 'P':                sscanf(line, "%c", &event);		print_dl();                /* your code... */                break;            /* Ignore everything else */            default:                /* Uncomment the line below when in debug mode *///                 printf("\n Ignoring line: %s", line);                break;        }    }    return (EXIT_SUCCESS);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -