Question
For this project you will write a program (in C++) to: a) read-in the 10 first names from a file (the file is a priori
For this project you will write a program (in C++) to:
a) read-in the 10 first names from a file (the file is a priori known to have exactly 10 entries, of a maximum length of 8 letters each) into a twodimensional character array,
b) output the names to the terminal with each one preceded by a number indicating its original order in the list,
c) sort the list of names, and then
d) output the sorted names both to the terminal and to a file, again with each one preceded by its corresponding original order in the list. Although an example input file (Names.txt) is provided, for grading purposes your project will be tested against a file that we will supply but will not be provided to you beforehand. Our test file will be in the same format as the example input file.
The following minimum functionality and structure is required:
Ask the user for the input and output file names.
Read in the list of names from the desired input file.
Store the names list in a two-dimensional character array (Use character arrays (i.e., C-style) to hold your strings)
Print out the unsorted list of names to the terminal, preceded by their original order in the input file.
Sort the list of names alphabetically.
Print the list of sorted names to the terminal, preceded by their original order in the input file.
Write the list of sorted names to a different output file (e.g. SortedNames.txt), preceded by their original order in the input file.
Write multiple functions.
Write your own C-string copy, C-string compare (or other) functions as needed. The following are a list of restrictions:
No usage of external libraries for C-string manipulation is allowed (e.g. ), or any std::string libraries and data types.
No libraries except and are allowed.
No global variables or constants except: a) the fixed number of names, and b) the maximum C-string size.
No usage of pointers or dynamic memory.
Example Input File (Names.txt)
Contents:
Victor
Eve
Juliet
Hector
Danielle
Romeo
Oscar
June
Ares
Dannae
Example Output (to Terminal and/or File):
Unsorted Data (Original Input Order and Name)
=============================
0 Victor
1 Eve
2 Juliet
3 Hector
4 Danielle
5 Romeo
6 Oscar
7 June
8 Ares
9 Dannae
Sorted Data (Original Input Order and Name)
===========================
8 Ares
4 Danielle
9 Dannae
1 Eve
3 Hector
2 Juliet
7 June
6 Oscar
5 Romeo
0 Victor
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started