Answered step by step
Verified Expert Solution
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 opensource development tools are free, but there are other important reasons for learning to use opensource tools and commandline tools. Automation of testing and other development tasks is often easier with commandline tools because it can be done with shell scripts or Python and doesn't require automation to be built into the tool. Also, commandline tools are easily used remotely. In addition to managing different versions of a project, Git is useful for collaboration and backup
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.
pc 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 doThe dollar signs represent the shell's command prompt.
$ mkdir p
$ cd p
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 : Makefiles page and in the Makefile video found in Module
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 pc
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 CS Summer
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 oneline 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:
$ p
Here is an example of the output from executing the program:
$ p
Program by Brian Durney
Argument #:p
Number of arguments printed:
Here's another example:
$ p Supplying 'multiple arguments' to this program
Program by Brian Durney
Argument #:p
Argument #:Supplying
Argument #:multiple arguments
Argument #:to
Argument #:this
Argument #:program
Number of arguments printed:
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 pc
$ 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 : 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 ptar.gz p
You should now have a file called ptar.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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started