EECS 183 Lab 8: File IO

Lab attendance Due at your scheduled lab time and day, Thursday or Friday, March 25th or 26th

Lab assignment Due Monday, March 29, 2021, 11:59 pm Eastern

In this lab, you are writing code to master the use of File IO and pass-by-reference. You will also get a head start on Project 4.


Attend the discussion with your lab instructor at your assigned lab time. Check here for the lab section Zoom link

You will complete this lab in small groups of about 4 students. For all labs in EECS 183, to receive a grade, every student must individually submit the Lab assingment.

Starter Files

You can download the starter files using this link.

The IDE setup tutorials for Visual Studio and XCode include a video about how to set up a project using the starter files. You can access the tutorials here:

After downloading and unzipping, you will find the following files in the starter-files folder:

IMPORTANT: For this lab, you must include all files in a single project in Xcode or Visual Studio.

IMPORTANT: Do not change any part of the header file coordinates.h.

Lab Assignment

Tasks to Complete

To complete this portion of the lab, you need to do the following steps:

  1. Start a new project with your IDE using the starter files according.
  2. Write your test cases in lab8.cpp to test the functions you will implement in coordinates.cpp.
  3. Write the implementations for the functions in coordinates.cpp:
  4. Test your functions using the test cases you have written.
  5. Submit your coordinates.cpp to the autograder.


Think a two-dimensional coordinate system: (row, column).

IMPORTANT: A Position of (1,A) will be stored as having row being 0 and col being 0


This function is used to ensure a value is within the valid range for a valid grid, shown above.


This function will read a value from the input stream is and modify row and col with the values read.

The RME for read() states: col is NOT case senstive, so reading should work for, e.g., “(1,a)” or “1a” or “(1,A)” or “1A”. A useful function to help with this is toupper(), which you can find in zyBooks Chapter 9 Section 1. Be careful though - toupper() returns an int. Make sure to explicitly cast it to a char before using it!

NOTE: You may assume that the row and column values read are single characters. You may also assume that the row value will be in the range (0,9) and column value will be in the range (A,Z) or (a,z). You must utilize check_range to make sure row and col are withing the correct bounds.


This function will write the values of row and col to the output stream os Writes position in form (row,col) where row is in range [1, 8] and col should be an uppercase letter in range [A, H].

To accomplish this, you must:

Note: your write function will not write coordinates in pairs of lines!

File Locations - Xcode

There are a few things that must be done for Xcode. First, ensure that Derived Data is stored relative to your project folder. Select Xcode > Preferences in the menu bar, click on Locations icon at the top on the window and choose Relative next to Derived Data. This will ensure that executables are saved in your Project folder.

Then, tell Xcode to look for files in the folder where all other project files are stored. From the menu bar, choose Product > Scheme > Edit Scheme.

Select Run on the left, Options on top and then select the checkbox Use custom working directory and navigate to your Project folder where you will store input files.

Now you can place input txt files right with your .h and .cpp files.

NOTE: If you move your project folder, you’ll have to reset the project’s working directory.

File Locations - Visual Studio

Fortunately, Visual Studio’s working directory is the project folder itself. So head to the project folder that is named the same as the project. There should be another folder with that same name. Place the input files in that second folder.

How to Submit

IMPORTANT: For all labs in EECS 183, to receive a grade, every student must individually submit the Lab Submission. Late submission for Labs will not be accepted for credit. For this lab, you will receive ten submissions per day with feedback.