Development Index

Libraries

Basic

include <unistd.h>
fork, pipe and I/O primitives (read, write, close, etc.) + primitve types like uid_t, pid_t etc
#include <stdlib.h>
Standard lib, contains primitves for number conversion and memory allocation
#include <stdio.h>
Basic i/o lib: printf etc
glibc
#include <string.h>
String manipulations
glibc
#include <time.h>
Time related functions
glibc
#include <signal.h>
Signal handling
glibc
#include <stdbool.h>
Boolean type
glibc
#include <math.h>
Math functions
glibc

Advanced

#include <sys/socket.h>
Socket connections
glibc
#include <sys/types.h>
Primitive types like uid_t, pid_t etc
glibc
#include <netinet/in.h>
internet address family
glibc
#include <arpa/inet.h>
definitions for internet operations
glibc
#include <pthread.h>
threads
glibc
#include <stdatomic.h>
mutual exclusion locks
gcc

Random Numbers

        // seed with current time:
        // time_t t;
        // srand(time(&t));
        void srand(unsigned seed);

        int rand(void);
        

Signals

        sig_t signal(int sig, sig_t func);

        int raise(int sig);

        int kill(pid_t pid, int sig);
        

Sorting

        void qsort(void* values, size_t num_items, size_t item_size, int (*comparefunc)(const void*, const void*));
        

Strings

        // SUCCESS: pointer to destination string
        char *strcpy(char *dest, const char *src);

        // result == 0 -> strings are equal
        // result < 0 -> str1 less than str2
        // result > 0 -> str2 less than str1
        int strcmp(const char *str1, const char *str2);;

        // result == NULL -> no tokens left to retrieve
        // else: pointer to last token found
        char *strtok(char *str, const char *delim);

        // NULL if no match
        // else: pointer to first occurence in string
        char *strstr(const char *string, const char *substring);

        // ERROR: result == 0
        int atoi(const char *str);
        

Inter Process Communication