Tips for including headers in c

1 minute read

If we use high level languages and get used to developer environments such as visual studio, eclipse, android studio, inclusion and import are very easy. In order to develop c language in vi environment, basic knowledge about header is required. I hope the following headers and their comments can help you.

Major headers for using standard c libraries

#include <stdio.h>           /* printf,fseek,fgets                */
#include <string.h>          /* strcpy,strcmp,strcat,memcpy       */
#include <stdlib.h>          /* getenv,atoi,atol                  */
#include <fcntl.h>           /* open,creat,dup,dup2               */
#include <unistd.h>          /* getpid,getpgrp,exec,access,getopt */
#include <time.h>            /* localtime,mktime,difftime         */
#include <sys/time.h>        /* gettimeofday                      */
#include <signal.h>          /* signal,sigaction,sigemptyset      */
#include <errno.h>           /* errno,strerror                    */
#include <sys/types.h>       /* pid_t,off_t                       */
#include <sys/resource.h>    /* getrlimit                         */
#include <sys/stat.h>        /* stat,fstat,umask,mkdir            */
#include <stdarg.h>          /* vprintf                           */
#include <sys/wait.h>        /* waitpid                           */
#include <sys/shm.h>         /* shmget                            */
#include <sys/ipc.h>         /* ftok                              */
#include <sys/msg.h>         /* SystemV(IPC) Message Queue        */
#include <mqueue.h>          /* POSIX Message Queue               */
#include <pthread.h>         /* pthread_create,pthread_join       */
#include <netinet/in.h>      /* sockaddr_in                       */
#include <netinet/tcp.h>     /* setsockopt options                */
#include <arpa/inet.h>       /* inet_addr,inet_ntoa               */
#include <sys/socket.h>      /* socket,accept,setsockopt          */
#include <sys/mman.h>        /* munmap                            */
#include <sys/un.h>          /* sockaddr_un                       */
#include <math.h>            /* M_PI,HUGE                         */
#include <netdb.h>           /* hostent,gethostbyaddr             */
#include <ctype.h>           /* isspace                           */
#include <sys/poll.h>        /* poll, pollfd                      */
#include <search.h>          /* hcreate,hsearch                   */
#include <libgen.h>          /* basename, dirname                 */

Tags: ,

Categories:

Updated:

Leave a comment