IIT Bombay
CS 101 Lab 9 Exercises on Text/Strings
Tuesday March 16th, 2011
Problem 1:
1. Your program accepts 2 command line arguments: both are file names.
2. Count how many times each string in the first file appears in
the second file, and display the result.
For example, if you execute your program as a.out list sample,
and if the
files list and sample are these: list sample, the
output of your program is:
for: 4 times
cout: 4 times
cin: 3 times
Problem 2:
Pick random pages from texts available here.
Using your program 1, study the use of certain grammatical features in them. Based on your
observations, make program2
which will attempt guessing the author given another random text.
Example features that you can use: articles, articles at the beginning of sentences, sentences
ending with "ing", words ending with "ing", words such as "I", "you", "we", "us" etc.
Submission: the cpp files
and a readme mentioning the
status of your program
Deadline: 11 pm.
Class programs for your reference:
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)