0% found this document useful (0 votes)
14 views2 pages

ICST102 Lab10

This document provides specifications for a C++ program that manipulates string data. The program takes input from a file containing a number of string pairs on separate lines. It is to print, compare for equality, and concatenate each pair of strings by calling defined functions. Sample input and output are given as examples. The functions print, my_compare, and my_concatenate are defined to handle the string operations, with print displaying the strings, my_compare returning 0 for equality and non-0 for inequality, and my_concatenate returning the concatenated string.

Uploaded by

Giovanni Moso
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

ICST102 Lab10

This document provides specifications for a C++ program that manipulates string data. The program takes input from a file containing a number of string pairs on separate lines. It is to print, compare for equality, and concatenate each pair of strings by calling defined functions. Sample input and output are given as examples. The functions print, my_compare, and my_concatenate are defined to handle the string operations, with print displaying the strings, my_compare returning 0 for equality and non-0 for inequality, and my_concatenate returning the concatenated string.

Uploaded by

Giovanni Moso
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

[ICST102] Computer Programming 1 First Semester, S/Y 2011-2012

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.

You might also like