Question: Project Overview: Given two input files, containing logs of text messages sent between two individuals, you should merge them into a single file that contains

Project Overview: Given two input files, containing logs of text messages sent between two individuals, you should merge them into a single file that contains a formatted transcript of their conversation. On the next page you can see two sample input files and the output file that you must generate from this input. Look at this example before reading any further.

The first input file is the messages sent from Person #1 to Person #2. The second input file is the messages sent from Person #2 to Person #1. Each file consists of one or more lines, where each line contains a single text message. The format is:

A sample input line would be: 1457737200 9 Toto, Ive a feeling were not in Kansas anymore.

The POSIX-time is an integer value that represents the number of seconds since January 1, 1970. 1457737200 translates to Friday, March 11, 2016 at 5:00pm (Central). To convert this integer to a readable date, use the function given below.

char *readableTime(int sec) { // this function takes an integer representing a time in seconds // it returns a formatted string that contains the date // the formatted string includes a newline character at the end time_t epoch_time = (time_t) sec; return asctime( localtime( &epoch_time ) );

}

You should merge the two files together in chronological order (from smallest POSIX-time to largest). A good algorithm for merging two input files into a single file is shown below:

Read an initial POSIX-time from each input file While there is data left in both input files (have not reached EOF on either file)

Process the line with the smallest POSIX-time

Read the next POSIX-time from that file If you have not yet reached EOF on the first input file, process the rest of the lines in that file If you have not yet reached EOF on the second input file, process the rest of the lines in that file

The required output format for the transcript file is specified below:

Text messages for Person #1 start at the left margin and are displayed in a 30-character width, longer messages should

wrap to multiple lines. After each message, display the date (right justified, in a readable format) on a separate line.

A 5-character blank space (buffer) exists between Person #1 and Person #2s text messages. With this buffer, a text

message for Person #2 would start 35 spaces from the left margin.

A 30-character width for is also used for Person #2s text messages, with each message followed by the date.

What You Need To Do

Create a directory called project3 on your machine. In that directory, create a file named text.c

In text.c, write the code needed to solve the problem stated above. Make sure that your program:

o Has a header block of comments that includes your name and a brief overview of the program o Use at least four functions (and has a brief comment describing the purpose of each function) o Gets the names of the two input files from the command line,as in ./text data1 data2 o Generates a transcript file in the current directory that contains a formatted output of the conversation

You may assume that both input files will always be non-empty and contain valid input.

We strongly recommend that you use scanner.h and scanner.c for all your input.

Make sure your program runs properly on cs-intro.ua.edu. Your program is graded on that system.

**NEW** You must generate a set of sample test data for this project (two input files).

**NEW** You must submit a Makefile for this project. When you are ready to submit your project:

Bundle your project3 directory (which should include at least text.c, scanner.c, scanner.h, Makefile, and two sample input files) into a single (compressed) zip file.

1457737200 9 Toto, I've a feeling we're not in Kansas anymore. 1457737205 6 We must be over the rainbow! 1457737210 7 Now I know we're not in Kansas. 1457737230 14 Who, me? Why, I'm not a witch at all. I'm Dorothy Gale from Kansas.

1457737250 5 Who, Toto? Toto's my dog. 1457737270 17 Oh, but I've already told you, I'm not a witch at all. Witches are old and ugly. 1457737275 3 Who was that? 1457737290 16 You are? Oh, I beg your pardon. But I've never heard of a beautiful witch before.

1457737220 9 Are you a good witch, or a bad witch? 1457737240 6 Oh!, Well, is that the witch? 1457737260 45 Well, I'm a little muddled. The Munchkins called me because a new witch has just dropped a house on the Wicked Witch of the East. And there's the house, and here you are, and that's all that's left of the Wicked Witch of the East. 1457737265 16 And so the Munchkins want to know are you a good witch, or a bad witch?

1457737280 16 The Munchkins. They're laughing because I am a witch. I'm Glinda, the Witch of the North. 1457737300 5 Only bad witches are ugly.

Toto, I've a feeling we're not in Kansas anymore.

Fri Mar 11 17:00:00 2016

We must be over the rainbow!

Fri Mar 11 17:00:05 2016

Now I know we're not in Kansas.

Fri Mar 11 17:00:10 2016

Who, me? Why, I'm not a witch at all. I'm Dorothy Gale from Kansas.

Fri Mar 11 17:00:30 2016

Who, Toto? Toto's my dog.

Fri Mar 11 17:00:50 2016

Are you a good witch, or a bad witch?

Fri Mar 11 17:00:20 2016

Oh!, Well, is that the witch?

Fri Mar 11 17:00:40 2016

Well, I'm a little muddled. The Munchkins called me because a new witch has just dropped a house on the Wicked Witch of the East. And there's the house, and here you are, and that's all that's left of the Wicked Witch of the East.

Fri Mar 11 17:01:00 2016

And so the Munchkins want to know are you a good witch, or a bad witch?

Fri Mar 11 17:01:05 2016

The Munchkins. They're laughing because I am a witch. I'm Glinda, the Witch of the North.

Fri Mar 11 17:01:20 2016

Only bad witches are ugly.

Oh, but I've already told you, I'm not a witch at all. Witches are old and ugly.

Fri Mar

Who was that?

Fri Mar

11 17:01:10 2016 11 17:01:15 2016

You are? Oh, I beg your pardon. But I've never heard of a beautiful witch before.

Fri Mar 11 17:01:30 2016

Fri Mar 11 17:01:40 2016

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!