Starting from:

$30

Homework Solution

Note: The purpose of this homework is to check that




You can use a simple Makefile
You can write a simple "Hello World" program in C++.
You are familiar with the tar command.
You are familiar with the handin command on CSIF computers.



Use the handin directory hw0 to submit your work




1) Write a C++ program that prints the following line on stdout:




Hello ECS36B from xxxxx




where the string xxxxx is replaced by the last five digits of your Student ID. The output should consist of a single line terminated by an end of line character. The output should consist of exactly 24 characters (including the end of line character). You can verify the length of the output using the Unix wc command.




The program source file name should be hello.cpp .




2) Write a Makefile such that the command




$ make




compiles the program hello.cpp and produces an executable named hello . The Makefile should include a target named clean so that the command




$ make clean




removes the executable file hello .




Create a tar file called hello.tar containing the files hello.cpp and Makefile. Do not use data compression to create the tar file.



Submit your file hello.tar using the handin command:



$ handin cs36b hw0 hello.tar




A script will be run in your handin hw0 directory and will execute the following commands:

$ tar xf hello.tar

$ make clean




$ make




$ ./hello hello.dat




The contents of hello.dat will then be checked.

More products