/******************************************************* * Filename: lab12.c * * Author: Sue Evans * * Date Written: 5/1/08 * * Section: 201staff * * EMail: bogar@cs.umbc.edu * * * * This file is the main driver for Lab 12, which will * * demonstrate opening files & validating command line * * arguments in addition the following linked list ops: * * - creating linked lists * * - deleting a specific node from a linked list * * - printing the linked lists * * - calling a function that removes a linked list * ********************************************************/ #include #include #include #include "linkedlist.h" /****************** Step 5a ***************/ /* #include "destroylist.h" */ #define NUM_SECTIONS 3 /******************* Step 2c *******************/ void ReadFile(FILE* ifp, NODEPTR sections[]); int main(int argc, char** argv) { FILE* ifp; int id; /* the id of the student to delete */ int i; /******************* Step 2a *******************/ NODEPTR head; /* Check the command line arguments */ if(argc != 2) { fprintf(stderr,"Not enough command line arguments!\n"); fprintf(stderr,"Use %s \n", argv[0]); exit(-1); } /* Make sure the datafile given at cmdline is valid. */ ifp = fopen(argv[1], "r"); if(ifp == NULL) { fprintf(stderr,"File %s could not be opened!\n", argv[1]); exit(-2); } printf("Welcome to the last lab of the semester! :) \n\n"); /******************* Step 2b ********************/ /* for(i = 0; i < NUM_SECTIONS; i++) { sections[i] = NULL; } */ /******************* Step 3b ******************/ /* ReadFile(ifp, sections); */ fclose(ifp); /******************* Step 3c ******************/ /* printf("\n\nDavid's Section :"); PrintList(sections[DAVID]); printf("\n\nJulia's Section :"); PrintList(sections[JULIA]); printf("\n\nAafreen's Section :"); PrintList(sections[AAFREEN]); */ /******************* Step 4a ********************/ /* printf("\nDelete a student from which section ?\n"); printf("\t1 - David\n"); printf("\t2 - Julia\n"); printf("\t3 - Aafreen\n"); printf("\n\tPlease enter the section number: "); scanf("%d", &i); i--; printf("\n\tPlease enter the id# to delete from the list: "); scanf("%d", &id); */ /******************* Step 4b ********************/ /* if (Delete(§ions[i], id) < 0 ) { printf("\tStudent was NOT in the class list.\n\n"); } else { printf("\tStudent was successfully deleted from class list.\n\n"); } */ /******************* Step 4c *********************/ /******************* Step 5b **********************/ return 0; } void ReadFile(FILE* ifp, NODEPTR sections[]) { STUDENT tempStudent; /* to hold contents just read in loop */ NODEPTR tempNode; /* ptr to a node just created */ char taName[NAMESIZE] = ""; /* will identify which list to Insert into */ /******************* Step 3a *******************/ }