If you don't already have a shell window on your screen, open one.
Use this shell window to do all the following!
Which files and sub-directories does your home directory contain?
Use the man command to look at the content of the manual page
for the command ls. What does the flag -a do?
Was your answer to the previos question entirely correct?
Create a sub-directory called lab-0 in your home directory.
Use cd to go to that directory,
and then write a small C program in a source file called Hello.c.
If you wish, you can use this program:
#include <stdio.h>
int main(void) {
printf("Hello, world!\n");
return 0;
}
Use gedit to write the program.
Use mv to change the name of the source file from Hello.c to hello.c.
We almost always use entirely lower-case letter for file names in Unix.
Compile the program with the C compiler gcc.
Make sure that the executable file is called hello.
Run the program.
Make some modifications to the source in hello.c.
Use emacs to edit the program!
Type make hello.
What happens?
Type make hello again.
What happens?
Make some modifications to the source in hello.c,
that will cause the compilation to fail.
Try to compile the program,
just to see how the error messages look.
When editing the program in Emacs, you can use the compile
command to compile your program.
Type ESC x c o m p i l e RETURN,
edit the command to use (for example to make hello),
and press RETURN again.
Emacs will open another buffer with the error messages.
Position the cursor on an error message
(for example by clicking with the mouse)
and press RETURN.
Emacs will go to the line in the program with the error.
If you have time:
Write a Makefile for the hello program.
Use cp with the flag -r
to make a copy of the entire sub-directory lab-0.
The copy should be called lab-0-copy.
Remove all the files in lab-0-copy.
Remove the directory lab-0-copy.
Report!
You don't have to write a report or present anyting from this exercise,
but if you have any questions or comments,
please discuss them with the teaching assistant.