CS/CE 218 Lab 2 5 September 1991 The report for this lab is due 6 September 1991 (tomorrow). Your report should be produced by editing this file, filling in answers to the questions below each question. When you are done, make a printout of your report. 0. Make a copy of /home/cs218/public/homework/lab2.txt in your (home) directory. Use emacs to read the file lab2.txt. (If you can see this sentence, you found it.) 1. (1 point) Each student in this class has a ``personal'' teaching assistant. Edit the file /home/cs218/public/ta-assignment.txt and find the line with your name. What is the name of your TA? 2. (1 point) Change the headings above to look something like the following. CS/CE 218 6 September 1991 Section 1 TA: Jano Lab Report 2 Ben Bittwiddle Be sure to use your own name, section, and TA! 3. (5 points) Put the following text into a file called ``hello.c''. (It's fastest in emacs to visit ``hello.c'', then yank the following text into the buffer ``hello.c''. If you type it, be sure to type it *exactly* as shown below.) #include main(int argc, char * argv) { printf("%c\n", "hello world!") } a) Compile hello.c using ``gcc -g'' (you can do this in emacs by first ensuring that you're in C mode, then typing ``M-x compile'' and when it prompts you for the ``Compile command'', deleting the default ``make -k'' and typing ``gcc -g hello.c''.) What is the output of the compilation? (In emacs, you can yank the contents of the *compilation* buffer into your lab report.) b) Add a semicolon (;) where indicated by gcc. Then compile the program again. If you have more than one error to correct, you've made a typing mistake (and aren't using emacs...). Ask a TA if you need help in finding the error. When you get the program to compile, run it (suspend emacs, then execute ``a.out''). What is the output? 4. (10 points) Run the program from part 3 under the debugger ``gdb''. (From emacs type ``M-x gdb'', and then when it prompts you with ``Run gdb on file: ~/'' add ``a.out'' to the file name, then type ``run'' followed by a carriage return.) What output do you see? 5. (extra credit only) How do yo set a breakpoint in gdb? (Read the info entry for gdb under emacs.) Try it out on a.out.