C Activity
Longest Line

Overview

This C programming exercise will introduce you to character arrays and the use of functions. The program will accept a series of lines from stdin and keep track of the longest line (most characters) entered.


Activity

Part I

Download the file longest.c to a directory named LongestLine. Complete the readline() function and verify that you can correctly echo each line as it is entered. An EOF (CTRL-D) terminates the program. You may assume that no input line is over 80 characters long.

> ./longest
this is a long line
this is a long line
this is a longer line
this is a longer line
(CTRL-D)

  1. Create an ActivityJournal.txt and estimate the time you will need to complete the program.
  2. Keep track of the number of times you attempt to compile your program and generate a compiler error of any type. Note that number in the Activity_Journal along with the actual time to complete the program. 
  3. Submit  your  source file - longest.c  and Activity_Journal in a directory named  LongestLine to your Git pushbox.

Part 2

Modify longest.c to  keep track of the longest line entered. Only print the longest line entered after input is complete. You will need to implement the copy() function to save the longest line.

> ./longest
This is a long line.
This is a longer line.
This is line has supercalifragilisticexpialidocious.
This is short.
(CTRL-D)
This is line has supercalifragilisticexpialidocious.

  1. Update Activity_Journal.txt and estimate the time you will need to complete the program.
  2. Keep track of the number of times you attempt to compile your program and generate a compiler error of any type. Note that number in the activity journal, along with the actual time to complete the program. 
  3. Place your  updated files - longest.c  and Activity_Journal - in directory LongestLine to your Git pushbox.