Professional Documents
Culture Documents
ICST102 Lab10
ICST102 Lab10
ICST102 Lab10
FILENAME: surname10.cpp
You are to write a program that demonstrates various manipulations that could be applied to data of type string. SPECIFICATIONS INPUT Your program should take input from a file named filein10.in which may contain several lines of input. The first line is an integer that contains the number of input to be read. The succeeding lines contain two single-word strings str1 and str2. OUTPUT For each line of input, you are to do the following: [a] echo / print the two strings to the screen; [b] determine whether the two strings are equal; and [c] concatenate the two strings. These should be done by functions which you will be defining. The prototypes for each function are given for your guidance: [a] void print(string str1, string str2) This function just prints the values of str1 and str2 to the screen. [b] int my_compare(string str1, string str2) This function compares two strings str1 and str2. It returns zero if the two strings are equal and a non-zero integer if the two are not equal. [c] string my_concatenate(string str1, string str2) This function concatenates two strings str1 and str2. It returns the concatenated string. SAMPLE INPUT 3 Hello world say goodbye lazy lazy SAMPLE OUTPUT Hello world The two strings are NOT equal! Helloworld
say goodbye The two strings are NOT equal! saygoodbye lazy lazy The two strings are equal! lazylazy
NOTE: Taking input and printing to the screen should be done within the main part of the program, not within the functions, except for print which essentially displays the two strings to the screen.