a guest Sep 8th, 2017 658 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- /* This is the main portion of the RSVP program, by Christopher Aden <email@example.com>.
- * All output is handled in this file. The file takes in function
- * prototypes from vector.h, course.h, and student.h, and the functions written
- * in their corresponding c files. The main will read into two structures: a student struc and a course struc.
- * The read in file is specified by the user with a command line argument.
- * The user is then presented with the menu of options, asking if they want to find a CRN
- * or subject, which sends them to a corresponding function. They are also given the ability to
- * add or remove classes from a user using a student ID. */
- #include <stdio.h>
- #include "vector.h"
- #include "course.h"
- //This function prompts the user for their RSVP choice. Their choice is assigned as an int and returned.
- int get_choice()
- int entry;
- printf("RSVP Menu\n");
- printf("0. Done.\n");
- printf("1. Find by CRN.\n");
- printf("2. Find by subject.\n");
- printf("3. Add course.\n");
- printf("4. Remove course.\n");
- printf("Your choice (0 - 4): ");
- scanf("%d", &entry);
- return entry;
- //Function takes in courses struc, student struc, and associated array sizes.
- //It will then enter a loop where it calls get_choice and gets an int value for the variable entry.
- //If entry is zero, the loop breaks. An entry value of 1 finds a CRN, 2 finds a subject, 3 adds a course to a student,
- // and 4 will remove a course. If neither 0, 1, 2, 3, nor 4 are entered, the choice is outside the range and the loop continues.
- void display_info(courseStruct * courses, studentStruct * students, int courseArraySize, int studentArraySize)
- int entry=5;
- while (1)
- entry = get_choice();
- if (entry == 0)
- else if (entry == 1)
- find_CRN(courses, students, courseArraySize, studentArraySize);
- else if (entry == 2)
- find_subject(courses, courseArraySize);
- else if (entry == 3)
- add_course(courses, &students, courseArraySize, studentArraySize);
- else if (entry == 4)
- remove_course(courses, &students, courseArraySize, studentArraySize);
- printf("Your choice is outside the acceptable range. Please try again.\n");
- //Main declares the course and student structures, and starting memory size ints.
- //It then reads in the source course list from command line argument 1 with the function
- //read_courses (written in course.c). Once the information is correctly entered into the strucs,
- //the user is presented with a main menu and chooses what they'd like to do.
- int main(int argc, char ** argv)
- courseStruct * courses; studentStruct * students;
- int courseArraySize = COURSE_ARRAY_SIZE, studentArraySize = STUDENT_ARRAY_SIZE;
- read_courses(argv, &courses, &courseArraySize);
- read_students(argv, &students, &studentArraySize);
- display_info(courses, students, courseArraySize, studentArraySize);
- return (0);
RAW Paste Data