Lab 3

The traditional, first program in C is "hello world". You can find copies of it everywhere, including on SNOWBALL under the professor's account.

Get a copy of a hello.c program, compile it with "gcc", e.g. "gcc hello.c -o hello", making sure that the output name (after -o) is different from the first. Then run the program.

Copy this program to a new file, called "lab3.c". Next, use an editor (e.g. vi) to edit the new program. On the line after "hello world!", have it print your name followed by "was here". Compile it, run it, and make sure that it works.

Make a log file. It should show both programs (i.e. use the "cat" command). It should show the compilations and runs.

Suppose that someone does the following:

$ cp hello.c test.c
$ gcc test.c -o test.c

The preceding command is a mistake, and you do not have to actually do this. What do you expect will happen, and why?

Use "echo" followed by the text for your answer. This answer should appear in your log.