I have this assignment to do, and it is very difficult for me to understand the actual question, and even more so what to do.
Here is the program mission (translated):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Write a program that receive from the user 2 names of files:
-First: Input file
-Second: Output file
(Without input requests from the program- meaning only input)
Every line in the input file is supposed to include: 4 strings
The program needs to receive the 4 strings into an array of strings.
The program has to sort through use of strcmp the strings, and then print to the output file a new string
which includes the linking of the strings in a rising order with a "character space" between them through use of strcat and strcpy.
Other than that, at the beginning of each line of the output file, print the number of the line (starting from '0'), colon, and space.
For Example:
For book space information zone on line number 0, program will print: 0: book information space zone
For near name net nutrition on line number 148, program will print: 148: name near net nutrition
You may assume:
1.That there are 4 strings in every line of the input file.
2.That the maximum size of every single of the 4 strings is: 20.
3.That in the input file, all the strings are lower case letters only, without numbers.
If there will be an error in the opening of the files, send an error message to the standard output (meaning, print using cout):
"Failed to open the file nameOfFile\n"
|
So, here is the source of my confusion/incomprehension:
1. How do I receive a name of an input and output file? How am I supposed to place that in the actual code of the output/input? I only recall how to set the names in the programming writing itself (meaning, that I set the names, and the program does what it needs to do with what I set).
2. How do I find the line number of the text? It's like, the user enters input, and I am supposed to find on which line it is in the text?
3. Lexicographically speaking, how do I put all the words in order?
Note: I am
not looking for a coded answer to the question, I am just looking for some technical guidelines of how to perform general operations (alphabetical order, line numbers, general comprehension). So, please, don't think that I am requesting that you solve this problem for me. I just need some general guidelines to assist me......
Thanks!