c programing homework
CEG 2170
Laboratory 8 1. (10 pts) Write a program that prompts the user to enter a filename to be used for output (assume no more
than 24 characters). Use the scanf function to read the file name. Then prompt the user to enter a sentence
from the keyboard and write that sentence to the file whose name was entered. (Note: the sentence may
include spaces, so be sure to use an input function that can handle that case, but will not be longer than 80
characters.) Look at the output file to verify that it was written correctly.
2. (15 pts) Write a function that accepts two string variables as arguments, and returns a boolean true if the
strings are the same, and false otherwise. Write a driver program to test the function. The driver program
should prompt the user to enter the two strings from the keyboard, echo the input to the screen, and then
use the function to test the strings for equality, printing the results of the test to the screen. You may assume
the strings do not contain any spaces and will contain no more than 24 characters.
3. (25 pts) Write a program that accepts a user-entered string from the keyboard, and prints it to the screen
only if it starts with a certain character (also user-entered). The string, which may contain spaces, but will
not be longer than 30 characters, should be printed right justified in a field width of 35.
You should use the following functions:
-- a function that gets the character
-- a function gets the string
-- a function that takes the character and the string as arguments and returns a boolean true if the string starts
with the character (and false otherwise).
Add a loop so that the user may continue to enter strings and perform the output described above, until the
user indicates he/she wants to stop. Once the user has quit entering strings, print a count of the number of
strings entered, and the number of strings printed.
Page 1 of 1