Assignment 01: Hello CS355!

Due Friday, January 24, before midnight

The goals for this assignment are:

  • Try slack

  • Check your Github configuration

  • Look at the website

  • Write a C++ program

  • (Optional) Setup your development environment on your own machine

1. Try slack

I will be inviting you all to join the course slack channel. In the #social channel, say and introduce yourself:

  • What is your preferred name and pronouns?

  • Share with us your favorite emojji. :)

We will use Slack for

  • Course announcements

  • Links to zoom and calend.ly

  • Questions and errata for assignments and labs

You can also use Slack to talk directly to me and the TAs, or even to each other.

2. Check your Github configuration

Please go to github.com to register if you do not yet have a Github account. We will use github for assignments. Email the instructor (anormoyle at brynmawr.edu) with your github username.

*You will need to setup an SSH key for Github. Click here for instructions.

Your work for this class will be closed source. You will have repositories created for you within our class organization on Github. See below for details.

The repository configuration is different from CS223 (Systems Programming), so read carefully!

3. Read the class web pages

Start by reading through all of the class webpage! Bookmark this page on your browser, or use some other method that helps you keep this information handy. All course materials will be posted on the course webpage!

Pay special attention to the Schedule.

4. Hello C++

Verify that you can use Github, git, and C/C++. You can try this using a lab machine, or your own machine if you have setup your development environment there.

Clone the repository

Click on your username. This will create a repository for you. Next, clone it to your local machine.

git clone git@github.com:BrynMawr-CS355-S25/a01-USERNAME

This will download a local copy of the repository to your computer.

Hello

In the directory a01-USERNAME, create a file named hello.cpp. Implement a program that prints "Hello World" to the console.

$ make hello
$ ./hello
Hello World

Check in your file.

$ git add hello.cpp
$ git commit -m "proof of concept"
$ git push

Base16

In the directory, a01-USERNAME edit the file base16.cpp. Implement a program that inputs a binary file and outputs its contents to a text file as a hexadecimal string.

$ make
g++ -g -Wno-unused-variable -Wno-unused-but-set-variable base16.cpp -o base16
$ ./base16
usage: ./base16 < filename >
$ ./base16 float.bin
00002040
$ cat float.txt
00002040
$ hexedit float.bin
00000000   00 00 20 40  .. @

Requirements:

  • Compiles with make. (Do not modify the Makefile)

  • Accepts a file as a command line argument. If not file is given, output a usage message.

  • Reads in a binary file and outputs a text file. The above implementation also prints the contents to the console, in addition to writing the output to a file.

  • The input file should have the extension .bin. The output file should have the same base name but with extension .txt

  • No memory errors using valgrind

  • Adheres to the style guidelines and includes a header comment

To check for valgrind errors, run your program like so. Look for the message "no leaks are possible". Make sure there are no errors reported. We will talk more about valgrind in week 2 and 3.
$ valgrind ./base16
==5184== Memcheck, a memory error detector
==5184== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==5184== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==5184== Command: ./base16
==5184==
==5184==
==5184== HEAP SUMMARY:
==5184==     in use at exit: 0 bytes in 0 blocks
==5184==   total heap usage: 2 allocs, 2 frees, 2,048 bytes allocated
==5184==
==5184== All heap blocks were freed -- no leaks are possible
==5184==
==5184== For lists of detected and suppressed errors, rerun with: -s
==5184== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Submit your work to Github

Add and check in your program using git and then push your changes to Github. Run the following command inside your a01-USERNAME directory.

$ cd a01-USERNAME
$ git add *.c
$ git commit -m "Descriptive message"
$ git push

Run git status to check the result of the previous git command. Check the Github website to make sure that your program uploaded correctly.

5. (Optional) Set up a remote development environment with our server goldengate

A remote development environment will allow you to run code from goldengate, a remote server, from within an integrated development environment.

For this option, your need to use VS Code with the Remote-SSH extension to VS Code.

6. (Optional) Set up your own local development environment

A local development environment allows you to write code on your own desktop or laptop. With a local development environment, you will be able to run your code even after you graduate from college.

All programs must run on the lab’s Linux environment. Make sure you test your work on the lab machines if you work on your laptop!

6.1. Windows

  1. Open PowerShell and install wsl2: wsl --install. See documentation. Note that you may need to open powershell as an administrator.

  2. From the windows store, install Ubuntu.

Once installed, you can setup your development environment from a bash shell.

  1. Open PowerShell

  2. Type wsl to start the windows subsystem for linux. This will give your a bash prompt

  3. Then install your development tools

    1. sudo apt-get install cmake

    2. sudo apt-get install git

    3. sudo apt-get install g++

    4. sudo apt-get install vim

    5. sudo apt-get install libc6-dev-i386

    6. sudo apt-get install gcc-multilib

    7. sudo apt-get install hexedit

    8. sudo apt-get install valgrind

    9. sudo apt-get install gdb

For example, you get something like the following

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\alinen> wsl
WSL alinen@Balthazar:~$ sudo apt-get install make

etc
A quick way to open powershell is to type <WindowsKey>-'Q' and type 'powershell'.

6.2. MacOS

From terminal, run command xcode-select --install

You can follow the instructions here

Then, to install additional dependencies, execute the following commands form terminal

$ brew install vim
$ brew install git
$ brew install cmake
A quick way to open terminal is to use spotlight. From the keyboard, type the <cmd> and <spacebar>. Then type terminal at the popup edit field.

Unfortunately, valgrind and gdb cannot be run natively on mac. However, you may try running leaks or lldb which are similar. However, we recommend you still test on goldengate or a lab machine.

7. Grading Rubric

Assignment rubrics

Grades are out of 4 points.

  • Github setup and hello.cpp (1 point)

  • Slack setup and introduction (0.5 points)

  • C program (2.5 points)

Code rubrics

For full credit, your C programs must be feature-complete, robust (e.g. run without memory errors or crashing) and have good style.

  • Some credit lost for missing features or bugs, depending on severity of error

  • -12.5% for style errors. See the class coding style here.

  • -50% for memory errors

  • -100% for failure to checkin work to Github

  • -100% for failure to compile on linux using make