IIT Bombay
CS 101 Lab 9   Exercises on Text/Strings
Friday March 18th, 2011

Problem 1: 

 Implement the following functions. their meaning are given below.
 
 1.  int strCount (char *filename);
            returns a count of no. of strings in a text file identified by the filename in the parameter.
 2.  int sentenceCount (char *filename);
           returns a count of no. of sentences in the identified text file. A sentence is
        detected when the last character of a word is the full stop.
 3.  float averageSentenceLength (char *filename);
          returns average no. of words (strings) per sentence in the identified text file.
 4.  int nLetterWords (int n, char *filename);
          returns the no. of n letter words in the file identified by the filename in the parameter

Test these functions on text files.  A sample text file: sample


Problem 2

Implement a function that returns an array of unique strings in a file. The function has signature:
string * uniqueStrings (char *filename, int &size);
size will indicate no. of strings in the array returned when the call returns.
Thus size is used as output only parameter through call by reference.     
Try this function on texts extracted from files available here

Deadline: 11 pm.

Upload your cpp files, and also write about the results that you obtained with these functions.

strings (string class and member functions compare, find, insert, replace, size, capacity)
files  (ifstream for reading, ofstream for writing)
Command line arguments to main (argv[1],argv[2] will hold your two file names)
c++ reference manual