Goals of this Assignment:
Write a C or C++ program named matedit, which serves as a matrix editor. With it one can create new matrices and save them to disk, and read in previously-saved ones and edit and save them to disk afterward. Here are the key requirements:
% matedit filename nrows ncols
The last two arguments are optional. If they are present, then filename is taken to be the name of a new file to be created, with the specified numbers of rows and columns. If they are absent, filename is taken to be an existing file. The size of a matrix is fixed once it's created; it cannot be expanded or shrunken.
3 12 8
88 24 -2
I've used 4-space fields here, but you'll need larger ones. Typically there will be a lot of blank space in the display.
Move Cursor. The action will be to move the cursor to the cell at the specified row and column, at the rightmost digit of the number, e.g. the 2 in the number 12 above.
Enter numbers at Cursor. The action will be to enter the specified numbers (could be any number of them, but for convenience let's say there are at most 10), starting at the current cursor position, and in row-major order.
For instance, consider the matrix displayed above, and suppose the cursor is currently at the 12, and the user types
ec 5 13 168
Then two things will happen: The cursor will move to the 24, and the matrix display will now look like
3 5 13
168 24 -2
Save and Exit.
The TA will test your program on several examples of his choosing. But YOU must show the TA how to use the Linux od command to inspect the contents of your files.
Advice:
You may be accustomed to having programming assignments that spell things out for you, in the sense of giving you an outline of the program, telling you what modules to break the program into and so on. Most CS professors in our department, and across the nation, do NOT make assignments this way, because you would never develop the skill to "see the big picture" to design programs on your own. So, here and in all my assignments, I simply state what the program is supposed to do, and it is up to you to design your code to make it work as required. Similarly, I do not typically tell you in advance where the pitfalls are; I simply warn that they exist, as I did above in my "lurking" remark.
As stated in our course syllabus, the TA will be happy to give you hints on getting started, etc., but you have to get as far as you can on your own before seeking our help, as that is where you truly learn. Again, this does NOT mean we are discouraging you from seeking help from us; on the contrary, we are happy to help you, but only after you've really thought about it.