-
Book Overview & Buying
-
Table Of Contents
Extreme C
By :
As we have explained before, this book requires you to have a minimum level of knowledge and skill regarding computer programming. The minimum requirements are listed below:
In addition, it is strongly recommended to download the code repository and follow the commands given in the shell boxes. Please use a platform with Linux or macOS installed. Other POSIX-compliant operating systems can still be used.
You can download the example code files for this book from your account at www.packt.com/. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Extreme-C. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
In this book, we have used code boxes and shell boxes. Code boxes contain a piece of either C code or pseudo-code. If the content of a code box is brought from a code file, the name of the code file is shown beneath the box. Below, you can see an example of a code box:
#include <stdio.h>
#include <unistd.h>
int main(int argc, char** argv) {
printf("This is the parent process with process ID: %d\n",
getpid());
printf("Before calling fork() ...\n");
pid_t ret = fork();
if (ret) {
printf("The child process is spawned with PID: %d\n", ret);
} else {
printf("This is the child process with PID: %d\n", getpid());
}
printf("Type CTRL+C to exit ...\n");
while (1);
return 0;
}
Code Box 17-1 [ExtremeC_examples_chapter17_1.c]: Creating a child process using fork API
As you can see, the above code can be found in the ExtremeC_examples_chapter17_1.c file, as part of the code bundle of the book, in the directory of Chapter 17, Process Execution. You can get the code bundle from GitHub at https://github.com/PacktPublishing/Extreme-C.
If a code box doesn't have an associated filename, then it contains pseudo-code or C code that cannot be found in the code bundle. An example is given below:
Task P {
1. num = 5
2. num++
3. num = num – 2
4. x = 10
5. num = num + x
}
Code Box 13-1: A simple task with 5 instructions
There can sometimes be some lines shown in bold font within code boxes. These lines are usually the lines of code that are discussed before or after the code box. They are in bold font in order to help you find them more easily.
Shell boxes are used to show the output of the Terminal while running a number of shell commands. The commands are usually in bold font and the output is in the normal font. An example is shown below:
$ ls /dev/shm shm0 $ gcc ExtremeC_examples_chapter17_5.c -lrt -o ex17_5.out $ ./ex17_5.out Shared memory is opened with fd: 3 The contents of the shared memory object: ABC $ ls /dev/shm $
Shell Box 17-6: Reading from the shared memory object created in example 17.4 and finally removing it
The commands start either with $ or #. The commands starting with $ should be run with a normal user, and the commands starting with # should be run with a super user.
The working directory of a shell box is usually the chapter directory found in the code bundle. In cases when a particular directory should be chosen as the working directory, we give you the necessary information regarding that.
Bold: Indicates a new term, an important word. Words that you see on the screen, for example, in menus or dialog boxes, also appear in the text like this. For example: "Select System info from the Administration panel."
Warnings or important notes appear like this.
Tips and tricks appear like this.