Strings and Structures/assign4.c
int searchCourseInfo(const CourseInfo *courses, const size_t courseCount, int courseId, char *courseName){
    
    int resultIndex;
    
    int isFound = NOT_FOUND;
    
    //search for course id
    if(courseId != 0){
        
        resultIndex = binarySearch(courses, courseCount, courseId);
        if(resultIndex != NOT_FOUND){
            courses += resultIndex;
            displayCourseInfo(courses, 1);
            isFound = FOUND;
        }
        else printf("%s %d %s\n", "COURSE ID:", courseId, "WAS NOT FOUND");
    }
    //search for course name
    else if(courseName != NULL){

        resultIndex = linearSearch(courses, courseCount, NAME_FLAG, courseName);
        if(resultIndex != NOT_FOUND){
            courses += resultIndex;
            displayCourseInfo(courses, 1);
            isFound = FOUND;
        }
        else printf("%s %s %s\n", "COURSE NAME:", courseName, "WAS NOT FOUND");

    }
    
    return isFound;
}
/*
    searchCourseInfo: searches through an array for a value, only one value can be searched at a time, either name or id
    input: the array to be searched (courses), the size of array (courseCount), the searchKey (courseId or courseName)
    output: if found key 1, or -1 if not found
*/
searches through an array for a value, only one value can be searched at a time, either name or id
input: the array to be searched (courses), the size of array (courseCount), the searchKey (courseId or courseName)
output: if found key 1, or -1 if not found
searches through an array for a value only one value can be searched at a time either name or id input : the array to be searched ( courses ) the size of array ( courseCount ) the searchKey ( courseId or courseName ) output : if found key 1 or - 1 if not found
int searchCourseInfo(const CourseInfo *courses, const size_t courseCount, int courseId, char *courseName){
    int resultIndex;
    int isFound = NOT_FOUND;
    if(courseId != 0){
        resultIndex = binarySearch(courses, courseCount, courseId);
        if(resultIndex != NOT_FOUND){
            courses += resultIndex;
            displayCourseInfo(courses, 1);
            isFound = FOUND;
        }
        else printf("%s %d %s\n", "COURSE ID:", courseId, "WAS NOT FOUND");
    }
    else if(courseName != NULL){
        resultIndex = linearSearch(courses, courseCount, NAME_FLAG, courseName);
        if(resultIndex != NOT_FOUND){
            courses += resultIndex;
            displayCourseInfo(courses, 1);
            isFound = FOUND;
        }
        else printf("%s %s %s\n", "COURSE NAME:", courseName, "WAS NOT FOUND");
    }
    return isFound;
}
int searchCourseInfo ( const CourseInfo * courses , const size_t courseCount , int courseId , char * courseName ) { int resultIndex ; int isFound = NOT_FOUND ; if ( courseId != 0 ) { resultIndex = binarySearch ( courses , courseCount , courseId ) ; if ( resultIndex != NOT_FOUND ) { courses += resultIndex ; displayCourseInfo ( courses , 1 ) ; isFound = FOUND ; } else printf ( " \n " , " " , courseId , " " ) ; } else if ( courseName != NULL ) { resultIndex = linearSearch ( courses , courseCount , NAME_FLAG , courseName ) ; if ( resultIndex != NOT_FOUND ) { courses += resultIndex ; displayCourseInfo ( courses , 1 ) ; isFound = FOUND ; } else printf ( " \n " , " " , courseName , " " ) ; } return isFound ; }
searchCourseInfo: searches through an array for a value, only one value can be searched at a time, either name or id
input: the array to be searched (courses), the size of array (courseCount), the searchKey (courseId or courseName)
output: if found key 1, or -1 if not found
searchCourseInfo : searches through an array for a value only one value can be searched at a time either name or id input : the array to be searched ( courses ) the size of array ( courseCount ) the searchKey ( courseId or courseName ) output : if found key 1 or - 1 if not found
//search for course id //search for course name