Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your first assignment is to demonstrate that you know how to accomplish the following: Create a working Makefile Create a valid C source code file

Your first assignment is to demonstrate that you know how to accomplish the following:
Create a working Makefile
Create a valid C source code file that prints the command line options
Create a local Git repository, add a file to the repository, and check in the changes
Create a source code tarball to submit to Canvas
Submit a tarball to Canvas
Rationale
Most open-source development tools are free, but there are other important reasons for learning to use open-source tools and command-line tools. Automation of testing and other development tasks is often easier with command-line tools because it can be done with shell scripts or Python and doesn't require automation to be built into the tool. Also, command-line tools are easily used remotely. In addition to managing different versions of a project, Git is useful for collaboration and back-up.
Details
This assignment requires you to submit a compressed tarball to Canvas containing a complete build environment. Your first build environment should consist of the following files:
Makefile - In real life, there is quite a bit of flexibility when it comes to naming this file. But we're not in the real world, we're in school. The first letter must be capitalized.
p0.c - This file contains your source code.
Creating Your Build Environment
Your first step is to create a subdirectory in which you will store your build environment. The following two lines demonstrate what you need to do.(The dollar signs represent the shell's command prompt.)
$ mkdir p0
$ cd p0
Now that you have created your build environment, create your Git repository with this command:
$ git init
Writing Your Makefile
With the Git repository initialized, it's time to create your build files. First, we'll start with the Makefile. To enter the simple nano editor, type:
$ nano Makefile
Once you are in the nano editor, you will want to add the appropriate information to the Makefile. There is more information about Makefiles on the Linux Basics 2: Makefiles page and in the Makefile video found in Module 1.
To exit out of the nano editor, simply hold the Control key while you press the 'x' key. Follow the instructions to save your file.
Writing Your Source Code
Next, you want to create your source code. Again, you can use the nano editor. Just type the following command:
$ nano p0.c
Now add your source code. A very simple example can be found in the C source code example. This example is the most basic program. You need to modify this program in order to meet the following requirements:
Include the following information as comments at the top of your source code:
--Your Name
--Your class catalog number, section number and class term (CS3060-001 Summer 2017)
--Assignment number
Assign two parameters for your main function.
--The first parameter should be an integer such as int argc
--The second parameter should be an array of string pointers such as char *argv[]
Print a one-line description (your name and the assignment name) of your program.
Using a loop, print the contents of the array of string pointers passed as a parameter to the main function
After the loop is complete, print the number of strings that were printed
Once you have completely written your source code, you should be able to create an executable binary by typing the following command:
$ make
Running Your Program
If everything worked correctly, you should have an executable binary. You can now launch that executable by typing the following:
$ ./p0
Here is an example of the output from executing the program:
$ ./p0
Program 1 by Brian Durney
Argument #0:./p0
Number of arguments printed:1
Here's another example:
$ ./p0 Supplying 'multiple arguments' to this program
Program 0 by Brian Durney
Argument #0:./p0
Argument #1:Supplying
Argument #2:multiple arguments
Argument #3:to
Argument #4:this
Argument #5:program
Number of arguments printed:6
If you are experiencing problems at this point, check for errors in your Makefile or your source code and try again.
Git Commit
Once your Makefile and source code are correct, you will add your new files to the Git repository and commit your changes like this:
$ git add Makefile p0.c
$ git commit
You will be prompted for a commit log message. Write whatever you want that describes what you just did.
You can find more information about Git on the Linux Basics 3: Git page.
NOTE: Don't post programming assignments for this class in a public repository. Doing so is considered cheating.
Creating Your Compressed Tarball
Now it is time to create a compressed tarball for submission to Canvas. Simply perform the following:
$ cd ..
$ tar -czf p0.tar.gz p0
You should now have a file called p1.tar.gz that you can submit to Canvas. Copy it off the server using WinSCP (or another scp utility) and submit the file to Canvas before the assignment due date. Please do

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions