QuestionQuestion

Description:
You are responsible to the binary search algorithm with the input as an array of structures. Your b_search function will be built into a separate DLL as your test driver function

Program Specification:
int b_search (char* list, int count, char* token, int* num_found)
list - the array of structure containing the studen records
count - the number of valid array elements
token the input search string
num_found - the address of the output variable storing the exact number of matches

This function return the first Student ID# when ther is one of more matches. As long as there is match (CASE INSENSITIVE), it will continue looping until no more. If ther are no match at all, it should return zero and *num_found will also set to zero

Additional Information:
Hw2test.bat: use it to compile and excute
Hw2test.out: sample output files using the given data files and batch file
Hw2.data1 & hw2.data2: test data files
hw2.c: test driver program (Do Not Change)
B_search.c: your code goes into this file
B_search.h: Header file with function signature

Program checklist:
You will submit 2 files, b_search. c and readme file

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>

#include "b_search.h"

struct student
{
int ID;
char name[20];
};

int main(int argc, char** argv)
{
char *token;
FILE *fptr;
int id = 0;
int i = 0;
int num_found = 0;
struct student list[100]; /* array of structure */

if (argc != 3)
{
printf("Usage: %s filename token\n", argv[0]);
return 1;
}

token = argv[2];

printf("\n");

fptr = fopen((argv[1]), "rtc");
if (fptr == NULL)
      printf( "File %s was not opened\n",argv[1] );
else
   {
      /* Set pointer to beginning of file: */
      fseek( fptr, 0L, SEEK_SET );...
$35.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats