Assignment 2
This homework is worth 10 points.
When you finish this assignment you should be able to:
- Log into the Department's linux machines.
- Copy files from your instructor's directory.
- Edit and compile programs.
- Email source code to your instructor.
Complete the following tasks.
- Log onto your account on one of the the Department's linux machines.
- Copy the source code for this program from your instructor's directory to your directory
- Issue the command cp ~dbennett/130/homework2.C .
-
- cp is the copy command
- ~dbennett/130/homework2.C is the name of the file you are copying.
- ~dbennett/130 is the path to the file
- homework2.C is the actual file name
- There is a dot (.) at the end of the above command
- This is the filename you want to copy the file to.
- It could be any name, for example myHomework2.C.
- But in this case, the . means keep the same name.
- So this command will copy a file into your directory called homework2.C
- Typing ls will show the names of all the files in your home directory.
- Edit the file
- add a comment at the top to include your name.
- Add another message to the user at the end of the program.
- Depending on where you are use joe, pico, kate or some other editor.
- Compile this program
- This assumes that you have not renamed the program.
- g++ -o homework2 homework2.C
- g++ is the gnu c++ compiler.
- -o homework2 says name the output homework2
- homework2.C says to compile the code in the file homework2.C
- There are two possible results
- The program compiles.
-
- The syntax was correct, so move on to the next step.
- The program has syntax errors.
-
- In this case, there were syntax errors.
- Near line 23 something went went wrong.
- There is possibly a problem near line 24 as well
- These were due to a missing ; on line 20
-
- You will need to fix any syntax errors and recompile.
- This might be a problem right now, get help
- Me
- A tutor
- Someone else in the lab.
- Note, not all syntax errors will produce the same messages.
- Check to see that your program, and executable are in your directory
- ls
-
- you can get more information by typing ls -l
- Run your program.
- ./homework2
- You should be prompted for your name
- If you see the following you failed to compile your program, go back to step 4
-
- Send an email message to your instructor
- The subject should be CSCI 130 Homework2
- The body should contain a friendly greeting and a statement that homework 2 is attached.
- Attach the file homework2.C
- DO NOT attach the file homework2