We wish to extend our “search” program that we did in class; and in the process we will review character arrays, strings, file processing and arrays.  These are to be done during lab hour in class.  For each of the capital letter points below, I want a separate page handed in (number A,B,C very clearly!).  The purpose of this assignment is to review the C++ constructs for the exam and build up a sophisticated program that answers (first order logic) questions and finds statistics about a file.  MAKE SURE THAT YOU SAVE THE PORTIONS OF THIS CODE THAT YOU DO AS WE WILL CONTINUE TO EXTEND IT.

 

 

A)    Review of Arrays and File Processing:

 

a)      Declare a one dimensional integer array initialized to 0.  This array will hold counts for words in a file.  We are not sure how many words are in the file, so the size should be set to 100. Declare a two dimensional character array that can hold up to 100 words.  Save words.txt as part of your project.  For each word in the file, read it in, place it in the next consecutive available spot of the words array.  USE GETLINE (not >> operator)!!

 

For example if the file contains:

 

prerequisite

co-requisite

course

credit

permissions

 

Then the first two rows of your character array will hold (etc): 

 

p

r

e

r

e

q

u

i

s

i

t

e

\0

 

 

 

 

c

o

-

r

e

q

u

i

s

i

t

e

\0

 

 

 

 

 

 

Print out the character array to standard output (NOT WHILE YOU ARE READING IT IN, BUT AFTER IT IS FULL!)

 

Write a function that prompts the user for a word, and prints out whether or not the word is in the array.  (You should use the strcmp function for character arrays.)

 

B)     Write the exact same program as above using strings (#include<string>).