Question

In: Computer Science

*I JUST WANT A GENERAL WALKTHROUGH OF HOW TO DO THIS. PSEUDOCODE IS FINE. THANK-YOU. THIS...

*I JUST WANT A GENERAL WALKTHROUGH OF HOW TO DO THIS. PSEUDOCODE IS FINE. THANK-YOU. THIS IS IN C THE PROGRAMMING LANGUAGE.*

The program will require the following structure:

struct _data {                                 

   char *name;

   long number;

};

The program will require command line arguments:

int main(int argv, char **argc) {

       

Where argv is the number of arguments and argc is an array

holding the arguments (each is a string). Your program must catch

any case where no command line arguement was provided and print

a warning message (see below).

You MUST include/use the following functions, defined as follows:

int SCAN(FILE *(*stream)) - this function will open the file/stream

and return an integer indicating how many lines there are. Note that

I need to pass stream, which is a pointer, by reference. So I am

passing this as a pointer to a pointer.

struct _data *LOAD(FILE *stream, int size) - this function will

rewind file, create the dynamic array (of size), and read in the

data, populating the _data struct dynamic array. Note that stream

is passed by value this time. The function then returns the populated

array of struct.

void SEARCH(struct _data *BlackBox, char *name, int size) - this function

will get the dynamic array of struct passed to it, the name we are looking

for, and the size of the array. This function will then search the dynamic

array for the name. See below for examples.

void FREE(struct _data *BlackBox, int size) - this function will free up

all of the dynamic memory we allocated. Take note of the number of times

malloc/calloc were called, as you need to free that same number.

Finally, the data file will be called hw5.data and will be formatted as:

ron 7774013

jon 7774014

tom 7774015

won 7774016

HINTS:

------

Functions that will make things much easier:

getline()

feof()

strtok()

atoi()

SAMPLE RUNS:

------------

Case 1 - No command line argument provided.

[yourname@chef junk]$ ./CS230-5

*******************************************

* You must include a name to search for. *

*******************************************

Case 2 - Provided name is NOT in the list.

[yourname@chef junk]$ ./CS230-5 joe

*******************************************

The name was NOT found.

*******************************************

Case 3 - Provided name is in the list.

*******************************************

The name was found at the 2 entry.

*******************************************

Solutions

Expert Solution


Related Solutions

.So I have a project, I just want a general answer on how would you start...
.So I have a project, I just want a general answer on how would you start it. I have to make the Backend read/write from the database. What does that mean and how you u do that general example, please. in php please EX - would i just make a script that just connects to the database , or is it more to it
I just want the code blanking led for PIC microprocessor in MBLAB X Thank you
I just want the code blanking led for PIC microprocessor in MBLAB X Thank you
I want you guys to rewrite this lab procedure, and it is fine if it was...
I want you guys to rewrite this lab procedure, and it is fine if it was shorter than this. An air track was fitted with two photocell bridges, one on each side of the collision region. Each bridge was operating in a gate mode timer that allows the collection of time intervals before and after collision. To ensure that friction and gravity have minimal effects, the track was leveled. Before starting the experiment, we ensured that loss in velocity was...
I JUST WANT AN EXAMPLE ANSWER SO I CAN MAKE MY OWN. THANK YOU!! Conduct research...
I JUST WANT AN EXAMPLE ANSWER SO I CAN MAKE MY OWN. THANK YOU!! Conduct research on New York City's large soda ban. Pretend you work at the Paradise City attorney's office. Draft a law that restricts the sale of large sugary drinks in Paradise City. Make sure to define the types of drinks and types of sellers restricted by the law. Example Statute: Title XXXIV (Links to an external site.)Links to an external site. ALCOHOLIC BEVERAGES AND TOBACCO Chapter...
Please I can get a flowchart and a pseudocode for this java code. Thank you //import...
Please I can get a flowchart and a pseudocode for this java code. Thank you //import the required classes import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BirthdayReminder {       public static void main(String[] args) throws IOException {        // declare the required variables String sName = null; String names[] = new String[10]; String birthDates[] = new String[10]; int count = 0; boolean flag = false; // to read values from the console BufferedReader dataIn = new BufferedReader(new...
PLEASE I DONT WANT PICTURES FOR MY QUESTION JUST COPY PAST AS I DID HERE THANK...
PLEASE I DONT WANT PICTURES FOR MY QUESTION JUST COPY PAST AS I DID HERE THANK YOU FOR UNDERSTANDING. Assignment Question(s):                                                      Q1- A company wants to implement good internal control. What are the policies and procedures you can suggest to minimize human frauds and errors? (1Mark) Q2- Assume that you have a company. And the management team estimates that 3% of sales will be uncollectible. Give any amount of sales and prepare the journal entry using the percent of sales...
Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import...
Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import java.util.Scanner; ;//import Scanner to take input from user public class TestScore {    @SuppressWarnings("resource")    public static void main(String[] args) throws ScoreException {//main method may throw Score exception        int [] arr = new int [5]; //creating an integer array for student id        arr[0] = 20025; //assigning id for each student        arr[1] = 20026;        arr[2] = 20027;...
I want to draw a sphere and I want to rotate it, How can I do...
I want to draw a sphere and I want to rotate it, How can I do it in JOGL? ( I am working on a program to visualize the sun ) please provide a pic of the code.
I want to test to see if a die is fair. Why shouldn’t I just do...
I want to test to see if a die is fair. Why shouldn’t I just do one test to see if there are too many ones, one test to see if there are too many twos, one test to see if there are too many threes, etc.?
How do you translate this pseudocode go regular code in C++ int iMin = 0,i =...
How do you translate this pseudocode go regular code in C++ int iMin = 0,i = 0; for(j = 0; j < n - 1; j++) int iMin = j; for(i = j + 1; i < n; i++) if(a[i] < a[iMin]) iMin = i; if(iMin != j) swap(a[i], a[iMin]);
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT