&
) and the dereference operator (*
).
It is a brief introduction to C pointers. This assignment will also provide
you a reference when you implement this functionality in the LC3 assembly
language.
First read the Getting Started section below and then study the documentation for printnum.h in the Files tab to understand the details of the assignment.
Save Target As..
for each of the files.
printnum.h
(do not modify)printnum.c
(complete this file)testPrint.c
(do not modify)Makefile
(do not modify)cd
command can be used for this.
make
You should see the following output:
gcc -g -std=c11 -Wall -c printnum.c
gcc -g -std=c11 -Wall -c testPrint.c
gcc -g -std=c11 -Wall printnum.o testPrint.o -o testPrint
testPrint
and read how to run the
the program.
You now have a functioning program. However, it doesn't do anything!
printnum.c
,
study the documentation in found in the files tab.
Plan what you need to do before writing code.
The best way to complete the code is to follow a write/compile/test sequence. Do not attempt to write everything at once. Rather choose one function and do the following steps.
printnum.c
using
your favorite editor.printnum.c
using
make
. You will find it convenient to work with both a
terminal and editor window at the same time.
The function printNum()
must call printDigit()
to
print a single digit. Therefore, you might first write code in
printNum()
to do nothing but call printDigit()
with the numerator
parameter. Then you can write and debug
printDigit()
.
Now you might modify printNum()
to simply call
divRem()
with the parameters numerator/base
. You
may use C's printf()
to print the results. Now, write and debug
divMod()
. However, you may only use printf()
for debugging. Your final code may only use putchar()
.
Finally, since your two support functions are completely debugged, you may
write and debug the actual code for printNum()
.
printnum.c
using the
checkin
program. Use the name PAx. At the terminal
type:
~cs270/bin/checkin PAx printnum.c
The above command submits your assignment.
Relax, you are done with your assignment!