Question
These constants, struct and function prototypes are defined in the given givenA1.h header file. #define NUMBER_PROFS 6 This represents the number of professors. #define NUMBER_COURSES
These constants, struct and function prototypes are defined in the given givenA1.h header file.
#define NUMBER_PROFS 6 This represents the number of professors.
#define NUMBER_COURSES 10 This represents the number of courses.
#define MAX_STR 50 This will represent the maximum length of a string.
struct courseStruct { char courseName [MAX_STR], int courseID
};
This struct will represent a single course. The courseName field is a string that will represent the name of the course and the courseID field is an int that will represent the course id of that particular course.
For example, if course Programming has a course id 1300, then courseStruct used would have courseName as Programming and courseID as 1300.
int readCourse ( char filename [MAX_STR], struct courseStruct courseInfo [NUMBER_COURSES]
)
This function must read courseNames and courseID from a text file called courses.txt to populate the array of structs called courseInfo with course names and corresponding course ids. A sample courses.txt file is provided. The text file name courses.txt must be read as the first command-line argument (e.g., ./a.out courses.txt data.txt) and not from standard input. Note that the first 10 lines of this file store 10 course names, and the next 10 lines store 10 course IDs, assuming that NUMBER_COURSES is set to 10. Also note that course names may have multiple words in them (e.g. Introduction to Programming). All course IDs are integers.
The function will either return 1 (to indicate successful operation) or -1 to represent abnormal exit, which can be:
Passing a NULL file pointer to the function
Passing a file that has more lines than 2 times NUMBER_COURSES
Passing a file that has less lines than 2 times NUMBER_COURSES
In normal operation, this function will read in exactly 2 times NUMBER_COURSES lines.
Make sure you test this thoroughlythis and the readProfAndCoursesTaught function represent the backbone of this application. Some implementations of line-by-line file reading may inadvertently introduce an extra newline (' ') in the string returned to the developer, which will mess up our testing. This is an error that can become "consistent" throughout the program (for example, if you mistakenly read the strings as {"Programming , Introductory Programming , Object Oriented Programming , Data Structures , Software Systems Development and Integration , Intro to Databases , Analysis and design of Algorithms , Advanced OO ,Data Mining , Cyber SecurityProgramming "}, the rest of the program will likely run without error, only to fail the string comparison tests in grading. This is because the remaining functions will read and write the botched course names and assume they are correct.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started