stands for user john's home directory.Now use a text editor, such as vior pico, but not GUI based text editors, to create aC program hello.cthat outputs Hello World!Name the file hello.cand save it in directory hello.Compile your program with command gcc hello.c. This command compiles the source code hello.cinto an object file hello.o, and then links the object code with the necessary library routines to form a complete, executable, program nameda.out.Now list your current directory with command ls -lt. You will see your originalsource code hello.c, possibly the object code hello.oand the executable a.out.Now run the program a.outby typing the command ./a.out. Note the dot in this command, which indicates that the program a.outis under the current directory, denoted by a single dot ".". You should see the output Hello world!In C, we use functions such as printf, putchar, etc., to send output to the standardoutput, which is similar to System.out.printin Java and cout <<in C++. To use these functions, we must include the standard header file <stdio.h>(standard I/O header file).To see how to use the functions such as printf, type the manual command: man -s3 printf on the terminal. In this command, the option "-s 3" means section 3 of themanual. All standard C functions are grouped under section 3.Try to display the manual page for the standard C function exit too.3. Create a C source code file getFullName.cthat prompts the user (using fgets) toenter his full name. Compile and execute it.Note: since the above program is a new program, you should place it inside a different directory, such as ~/lab02/getFullName. In future exercises, each new program should be placed in a separate directory.
You've reached the end of your free preview.
Want to read all 5 pages?
home directory, current directory, C standard library