#include directive in c

Syntax:
#include <filename>
or
#include “filename”

Task of include directive is to include or import any type file. There are two form of include directive.

Form 1:
#include<filename>: This statement will search the file in include directory (Default location of include directory is c:\tc\include). If that file is present then #include statement is replaced by content of file. If that file is not present then it will cause of compilation error. For example: (In turbo C 3.0)

//test.c
#include<stdio.h>
#include<conio.h>
void main(){
    clrscr();
    printf("HOW large is this file?");
    getch();
}

In first look you may think above c program content only seven lines. But it is not true. If you will see its intermediate file first two include statement has been replaced by content of file stdio.h and conio.h respectively. Suppose you have saved above file at c:\tc\bin as test.c. First compile the test.c then in command prompt write:

c:\tc\bin>cpp test.c    (Press enter key)
c:\tc\bin>type test.i   (Press enter key)

You will get following intermediate file:     

test.c 1:
C:\TC\INCLUDE\stdio.h 1:
C:\TC\INCLUDE\stdio.h 2:
C:\TC\INCLUDE\stdio.h 3:
C:\TC\INCLUDE\stdio.h 4:
C:\TC\INCLUDE\stdio.h 5:
C:\TC\INCLUDE\stdio.h 6:
C:\TC\INCLUDE\stdio.h 7:
C:\TC\INCLUDE\stdio.h 8:
C:\TC\INCLUDE\stdio.h 9:
C:\TC\INCLUDE\stdio.h 10:
C:\TC\INCLUDE\stdio.h 11:
C:\TC\INCLUDE\stdio.h 12:
C:\TC\INCLUDE\stdio.h 13:
C:\TC\INCLUDE\_defs.h 1:
C:\TC\INCLUDE\_defs.h 2:
C:\TC\INCLUDE\_defs.h 3:
C:\TC\INCLUDE\_defs.h 4:
C:\TC\INCLUDE\_defs.h 5:
C:\TC\INCLUDE\_defs.h 6:
C:\TC\INCLUDE\_defs.h 7:
C:\TC\INCLUDE\_defs.h 8:
C:\TC\INCLUDE\_defs.h 9:
C:\TC\INCLUDE\_defs.h 10:
C:\TC\INCLUDE\_defs.h 11:
C:\TC\INCLUDE\_defs.h 12:
C:\TC\INCLUDE\_defs.h 13:
C:\TC\INCLUDE\_defs.h 14:
C:\TC\INCLUDE\_defs.h 15:
C:\TC\INCLUDE\_defs.h 16:
C:\TC\INCLUDE\_defs.h 17:
C:\TC\INCLUDE\_defs.h 18:
C:\TC\INCLUDE\_defs.h 19:
C:\TC\INCLUDE\_defs.h 20:
C:\TC\INCLUDE\_defs.h 21:
C:\TC\INCLUDE\_defs.h 22:
C:\TC\INCLUDE\_defs.h 23:
C:\TC\INCLUDE\_defs.h 24:
C:\TC\INCLUDE\_defs.h 25:    
C:\TC\INCLUDE\_defs.h 26:
C:\TC\INCLUDE\_defs.h 27:
C:\TC\INCLUDE\_defs.h 28:
C:\TC\INCLUDE\_defs.h 29:
C:\TC\INCLUDE\_defs.h 30:
C:\TC\INCLUDE\_defs.h 31:
C:\TC\INCLUDE\_defs.h 32:
C:\TC\INCLUDE\_defs.h 33:
C:\TC\INCLUDE\_defs.h 34:
C:\TC\INCLUDE\_defs.h 35:
C:\TC\INCLUDE\_defs.h 36:
C:\TC\INCLUDE\_defs.h 37:
C:\TC\INCLUDE\_defs.h 38:
C:\TC\INCLUDE\_defs.h 39:
C:\TC\INCLUDE\_defs.h 40:
C:\TC\INCLUDE\_defs.h 41:
C:\TC\INCLUDE\_defs.h 42:
C:\TC\INCLUDE\_defs.h 43:
C:\TC\INCLUDE\_defs.h 44:
C:\TC\INCLUDE\_defs.h 45:
C:\TC\INCLUDE\_defs.h 46:
C:\TC\INCLUDE\_defs.h 47:
C:\TC\INCLUDE\_defs.h 48:
C:\TC\INCLUDE\_defs.h 49:
C:\TC\INCLUDE\_defs.h 50:
C:\TC\INCLUDE\_defs.h 51:
C:\TC\INCLUDE\_defs.h 52:
C:\TC\INCLUDE\_defs.h 53:
C:\TC\INCLUDE\stdio.h 14:
C:\TC\INCLUDE\stdio.h 15:
C:\TC\INCLUDE\stdio.h 16:
C:\TC\INCLUDE\stdio.h 17:
C:\TC\INCLUDE\_null.h 1:
C:\TC\INCLUDE\_null.h 2:
C:\TC\INCLUDE\_null.h 3:
C:\TC\INCLUDE\_null.h 4:
C:\TC\INCLUDE\_null.h 5:
C:\TC\INCLUDE\_null.h 6:
C:\TC\INCLUDE\_null.h 7:
C:\TC\INCLUDE\_null.h 8:
C:\TC\INCLUDE\_null.h 9:
C:\TC\INCLUDE\_null.h 10:    
C:\TC\INCLUDE\_null.h 11:
C:\TC\INCLUDE\_null.h 12:
C:\TC\INCLUDE\_null.h 13:
C:\TC\INCLUDE\_null.h 14:
C:\TC\INCLUDE\_null.h 15:
C:\TC\INCLUDE\_null.h 16:
C:\TC\INCLUDE\_null.h 17:
C:\TC\INCLUDE\stdio.h 18:
C:\TC\INCLUDE\stdio.h 19:
C:\TC\INCLUDE\stdio.h 20:
C:\TC\INCLUDE\stdio.h 21:
C:\TC\INCLUDE\stdio.h 22: typedef unsigned size_t;
C:\TC\INCLUDE\stdio.h 23:
C:\TC\INCLUDE\stdio.h 24:
C:\TC\INCLUDE\stdio.h 25:
C:\TC\INCLUDE\stdio.h 26:
C:\TC\INCLUDE\stdio.h 27: typedef long    fpos_t;
C:\TC\INCLUDE\stdio.h 28:
C:\TC\INCLUDE\stdio.h 29:
C:\TC\INCLUDE\stdio.h 30:
C:\TC\INCLUDE\stdio.h 31:
C:\TC\INCLUDE\stdio.h 32: typedef struct  {
C:\TC\INCLUDE\stdio.h 33: int             level;         
C:\TC\INCLUDE\stdio.h 34: unsigned        flags;         
C:\TC\INCLUDE\stdio.h 35: char            fd;            
C:\TC\INCLUDE\stdio.h 36: unsigned char   hold;          
C:\TC\INCLUDE\stdio.h 37: int             bsize;         
C:\TC\INCLUDE\stdio.h 38: unsigned char   *buffer;  
C:\TC\INCLUDE\stdio.h 39: unsigned char   *curp;    
C:\TC\INCLUDE\stdio.h 40: unsigned        istemp;        
C:\TC\INCLUDE\stdio.h 41: short           token;         
C:\TC\INCLUDE\stdio.h 42: }       FILE;                          
C:\TC\INCLUDE\stdio.h 43:
C:\TC\INCLUDE\stdio.h 44:
C:\TC\INCLUDE\stdio.h 45:
C:\TC\INCLUDE\stdio.h 46:
C:\TC\INCLUDE\stdio.h 47:
C:\TC\INCLUDE\stdio.h 48:
C:\TC\INCLUDE\stdio.h 49:
C:\TC\INCLUDE\stdio.h 50:
C:\TC\INCLUDE\stdio.h 51:
C:\TC\INCLUDE\stdio.h 52:
C:\TC\INCLUDE\stdio.h 53:
C:\TC\INCLUDE\stdio.h 54:
C:\TC\INCLUDE\stdio.h 55:
C:\TC\INCLUDE\stdio.h 56:
C:\TC\INCLUDE\stdio.h 57:
C:\TC\INCLUDE\stdio.h 58:
C:\TC\INCLUDE\stdio.h 59:
C:\TC\INCLUDE\stdio.h 60:
C:\TC\INCLUDE\stdio.h 61:
C:\TC\INCLUDE\stdio.h 62:
C:\TC\INCLUDE\stdio.h 63:
C:\TC\INCLUDE\stdio.h 64:
C:\TC\INCLUDE\stdio.h 65:
C:\TC\INCLUDE\stdio.h 66:
C:\TC\INCLUDE\stdio.h 67:
C:\TC\INCLUDE\stdio.h 68:
C:\TC\INCLUDE\stdio.h 69:
C:\TC\INCLUDE\stdio.h 70:
C:\TC\INCLUDE\stdio.h 71:
C:\TC\INCLUDE\stdio.h 72:
C:\TC\INCLUDE\stdio.h 73:
C:\TC\INCLUDE\stdio.h 74:
C:\TC\INCLUDE\stdio.h 75:
C:\TC\INCLUDE\stdio.h 76:
C:\TC\INCLUDE\stdio.h 77:
C:\TC\INCLUDE\stdio.h 78:
C:\TC\INCLUDE\stdio.h 79:
C:\TC\INCLUDE\stdio.h 80:
C:\TC\INCLUDE\stdio.h 81:
C:\TC\INCLUDE\stdio.h 82:
C:\TC\INCLUDE\stdio.h 83:
C:\TC\INCLUDE\stdio.h 84:
C:\TC\INCLUDE\stdio.h 85:
C:\TC\INCLUDE\stdio.h 86:
C:\TC\INCLUDE\stdio.h 87:
C:\TC\INCLUDE\stdio.h 88:
C:\TC\INCLUDE\stdio.h 89:
C:\TC\INCLUDE\stdio.h 90:
C:\TC\INCLUDE\stdio.h 91:
C:\TC\INCLUDE\stdio.h 92:
C:\TC\INCLUDE\stdio.h 93:
C:\TC\INCLUDE\stdio.h 94:
C:\TC\INCLUDE\stdio.h 95:
C:\TC\INCLUDE\stdio.h 96:
C:\TC\INCLUDE\stdio.h 97:
C:\TC\INCLUDE\stdio.h 98:
C:\TC\INCLUDE\stdio.h 99:
C:\TC\INCLUDE\stdio.h 100:
C:\TC\INCLUDE\stdio.h 101:
C:\TC\INCLUDE\stdio.h 102:
C:\TC\INCLUDE\stdio.h 103: extern  FILE    cdecl _streams[];
C:\TC\INCLUDE\stdio.h 104: extern  unsigned    cdecl _nfile;
C:\TC\INCLUDE\stdio.h 105:
C:\TC\INCLUDE\stdio.h 106:
C:\TC\INCLUDE\stdio.h 107:
C:\TC\INCLUDE\stdio.h 108:
C:\TC\INCLUDE\stdio.h 109:
C:\TC\INCLUDE\stdio.h 110:
C:\TC\INCLUDE\stdio.h 111:
C:\TC\INCLUDE\stdio.h 112:
C:\TC\INCLUDE\stdio.h 113:
C:\TC\INCLUDE\stdio.h 114:
C:\TC\INCLUDE\stdio.h 115:
C:\TC\INCLUDE\stdio.h 116:
C:\TC\INCLUDE\stdio.h 117:
C:\TC\INCLUDE\stdio.h 118:
C:\TC\INCLUDE\stdio.h 119:
C:\TC\INCLUDE\stdio.h 120:
C:\TC\INCLUDE\stdio.h 121:
C:\TC\INCLUDE\stdio.h 122:
C:\TC\INCLUDE\stdio.h 123:
C:\TC\INCLUDE\stdio.h 124:
C:\TC\INCLUDE\stdio.h 125:
C:\TC\INCLUDE\stdio.h 126:
C:\TC\INCLUDE\stdio.h 127:
C:\TC\INCLUDE\stdio.h 128:
C:\TC\INCLUDE\stdio.h 129:
C:\TC\INCLUDE\stdio.h 130:
C:\TC\INCLUDE\stdio.h 131:
C:\TC\INCLUDE\stdio.h 132:
C:\TC\INCLUDE\stdio.h 133:
C:\TC\INCLUDE\stdio.h 134:
C:\TC\INCLUDE\stdio.h 135:
C:\TC\INCLUDE\stdio.h 136: void    cdecl clearerr(FILE *__stream);
C:\TC\INCLUDE\stdio.h 137: int     cdecl fclose(FILE *__stream);
C:\TC\INCLUDE\stdio.h 138: int     cdecl fflush(FILE *__stream);
C:\TC\INCLUDE\stdio.h 139: int     cdecl fgetc(FILE *__stream);
C:\TC\INCLUDE\stdio.h 140: int     cdecl fgetpos(FILE *__stream, fpos_t *__pos);
C:\TC\INCLUDE\stdio.h 141: char   *cdecl fgets(char *__s, int __n, FILE *__stream);
C:\TC\INCLUDE\stdio.h 142: FILE   *cdecl fopen(const char *__path, const char *__mode);
C:\TC\INCLUDE\stdio.h 143: int     cdecl fprintf(FILE *__stream, const char *__format, ...);
C:\TC\INCLUDE\stdio.h 144: int     cdecl fputc(int __c, FILE *__stream);
C:\TC\INCLUDE\stdio.h 145: int     cdecl fputs(const char *__s, FILE *__stream);
C:\TC\INCLUDE\stdio.h 146: size_t  cdecl fread(void *__ptr, size_t __size, size_t __n,
C:\TC\INCLUDE\stdio.h 147: FILE *__stream);
C:\TC\INCLUDE\stdio.h 148: FILE   *cdecl freopen(const char *__path, const char *__mode,
C:\TC\INCLUDE\stdio.h 149: FILE *__stream);
C:\TC\INCLUDE\stdio.h 150: int     cdecl fscanf(FILE *__stream, const char *__format, ...);
C:\TC\INCLUDE\stdio.h 151: int     cdecl fseek(FILE *__stream, long __offset, int __whence);
C:\TC\INCLUDE\stdio.h 152: int     cdecl fsetpos(FILE *__stream, const fpos_t *__pos);
C:\TC\INCLUDE\stdio.h 153: long    cdecl ftell(FILE *__stream);
C:\TC\INCLUDE\stdio.h 154: size_t  cdecl fwrite(const void *__ptr, size_t __size, size_t __n,
C:\TC\INCLUDE\stdio.h 155: FILE *__stream);
C:\TC\INCLUDE\stdio.h 156: char   *cdecl gets(char *__s);
C:\TC\INCLUDE\stdio.h 157: void    cdecl perror(const char *__s);
C:\TC\INCLUDE\stdio.h 158: int     cdecl printf(const char *__format, ...);
C:\TC\INCLUDE\stdio.h 159: int     cdecl puts(const char *__s);
C:\TC\INCLUDE\stdio.h 160: int     cdecl remove(const char *__path);
C:\TC\INCLUDE\stdio.h 161: int     cdecl rename(const char *__oldname,const char *__newname);
C:\TC\INCLUDE\stdio.h 162: void    cdecl rewind(FILE *__stream);
C:\TC\INCLUDE\stdio.h 163: int     cdecl scanf(const char *__format, ...);
C:\TC\INCLUDE\stdio.h 164: void    cdecl setbuf(FILE *__stream, char *__buf);
C:\TC\INCLUDE\stdio.h 165: int     cdecl setvbuf(FILE *__stream, char *__buf,
C:\TC\INCLUDE\stdio.h 166: int __type, size_t __size);
C:\TC\INCLUDE\stdio.h 167: int     cdecl sprintf(char *__buffer, const char *__format, ...);
C:\TC\INCLUDE\stdio.h 168: int     cdecl sscanf(const char *__buffer,
C:\TC\INCLUDE\stdio.h 169: const char *__format, ...);
C:\TC\INCLUDE\stdio.h 170: char   *cdecl strerror(int __errnum);
C:\TC\INCLUDE\stdio.h 171: FILE   *cdecl tmpfile(void);
C:\TC\INCLUDE\stdio.h 172: char   *cdecl tmpnam(char *__s);
C:\TC\INCLUDE\stdio.h 173: int     cdecl ungetc(int __c, FILE *__stream);
C:\TC\INCLUDE\stdio.h 174: int     cdecl vfprintf(FILE *__stream, const char *__format,
C:\TC\INCLUDE\stdio.h 175: void *__arglist);
C:\TC\INCLUDE\stdio.h 176: int     cdecl vfscanf(FILE *__stream, const char *__format,
C:\TC\INCLUDE\stdio.h 177: void *__arglist);
C:\TC\INCLUDE\stdio.h 178: int     cdecl vprintf(const char *__format, void *__arglist);
C:\TC\INCLUDE\stdio.h 179: int     cdecl vscanf(const char *__format, void *__arglist);
C:\TC\INCLUDE\stdio.h 180: int     cdecl vsprintf(char *__buffer, const char *__format,
C:\TC\INCLUDE\stdio.h 181: void *__arglist);
C:\TC\INCLUDE\stdio.h 182: int     cdecl vsscanf(const char *__buffer, const char *__format,
C:\TC\INCLUDE\stdio.h 183: void *__arglist);
C:\TC\INCLUDE\stdio.h 184: int     cdecl unlink(const char *__path);
C:\TC\INCLUDE\stdio.h 185: int     cdecl getc(FILE *__fp);
C:\TC\INCLUDE\stdio.h 186:
C:\TC\INCLUDE\stdio.h 187: int     cdecl getchar(void);
C:\TC\INCLUDE\stdio.h 188: int     cdecl putchar(const int __c);
C:\TC\INCLUDE\stdio.h 189:
C:\TC\INCLUDE\stdio.h 190: int     cdecl putc(const int __c, FILE *__fp);
C:\TC\INCLUDE\stdio.h 191: int     cdecl feof(FILE *__fp);
C:\TC\INCLUDE\stdio.h 192: int     cdecl ferror(FILE *__fp);
C:\TC\INCLUDE\stdio.h 193:
C:\TC\INCLUDE\stdio.h 194:
C:\TC\INCLUDE\stdio.h 195:
C:\TC\INCLUDE\stdio.h 196: int     cdecl fcloseall(void);
C:\TC\INCLUDE\stdio.h 197: FILE   *cdecl fdopen(int __handle, char *__type);
C:\TC\INCLUDE\stdio.h 198: int     cdecl fgetchar(void);
C:\TC\INCLUDE\stdio.h 199: int     cdecl flushall(void);
C:\TC\INCLUDE\stdio.h 200: int     cdecl fputchar(int __c);
C:\TC\INCLUDE\stdio.h 201: FILE   * cdecl _fsopen (const char *__path, const char *__mode,
C:\TC\INCLUDE\stdio.h 202: int __shflag);
C:\TC\INCLUDE\stdio.h 203: int     cdecl getw(FILE *__stream);
C:\TC\INCLUDE\stdio.h 204: int     cdecl putw(int __w, FILE *__stream);
C:\TC\INCLUDE\stdio.h 205: int     cdecl rmtmp(void);
C:\TC\INCLUDE\stdio.h 206: char   * cdecl _strerror(const char *__s);
C:\TC\INCLUDE\stdio.h 207: char   * cdecl tempnam(char *__dir, char *__pfx);
C:\TC\INCLUDE\stdio.h 208:
C:\TC\INCLUDE\stdio.h 209:
C:\TC\INCLUDE\stdio.h 210:
C:\TC\INCLUDE\stdio.h 211:
C:\TC\INCLUDE\stdio.h 212: int      cdecl _fgetc(FILE *__stream);          
C:\TC\INCLUDE\stdio.h 213: int      cdecl _fputc(char __c, FILE *__stream);
C:\TC\INCLUDE\stdio.h 214:
C:\TC\INCLUDE\stdio.h 215:
C:\TC\INCLUDE\stdio.h 216:
C:\TC\INCLUDE\stdio.h 217:
C:\TC\INCLUDE\stdio.h 218:
C:\TC\INCLUDE\stdio.h 219:
C:\TC\INCLUDE\stdio.h 220:
C:\TC\INCLUDE\stdio.h 221:
C:\TC\INCLUDE\stdio.h 222:
C:\TC\INCLUDE\stdio.h 223:
C:\TC\INCLUDE\stdio.h 224:
C:\TC\INCLUDE\stdio.h 225:
C:\TC\INCLUDE\stdio.h 226:
C:\TC\INCLUDE\stdio.h 227:
C:\TC\INCLUDE\stdio.h 228:
C:\TC\INCLUDE\stdio.h 229:
C:\TC\INCLUDE\stdio.h 230:
C:\TC\INCLUDE\stdio.h 231:
C:\TC\INCLUDE\stdio.h 232:
C:\TC\INCLUDE\stdio.h 233:
C:\TC\INCLUDE\stdio.h 234:
C:\TC\INCLUDE\stdio.h 235:
C:\TC\INCLUDE\stdio.h 236:
C:\TC\INCLUDE\stdio.h 237:
C:\TC\INCLUDE\stdio.h 238:
C:\TC\INCLUDE\stdio.h 239:
C:\TC\INCLUDE\stdio.h 240:
test.c 2:
C:\TC\INCLUDE\conio.h 1:
C:\TC\INCLUDE\conio.h 2:
C:\TC\INCLUDE\conio.h 3:
C:\TC\INCLUDE\conio.h 4:
C:\TC\INCLUDE\conio.h 5:
C:\TC\INCLUDE\conio.h 6:
C:\TC\INCLUDE\conio.h 7:
C:\TC\INCLUDE\conio.h 8:
C:\TC\INCLUDE\conio.h 9:
C:\TC\INCLUDE\conio.h 10:
C:\TC\INCLUDE\conio.h 11:
C:\TC\INCLUDE\conio.h 12:
C:\TC\INCLUDE\conio.h 13:
C:\TC\INCLUDE\conio.h 14:
C:\TC\INCLUDE\conio.h 15:
C:\TC\INCLUDE\conio.h 16:
C:\TC\INCLUDE\conio.h 17:
C:\TC\INCLUDE\conio.h 18:
C:\TC\INCLUDE\conio.h 19:
C:\TC\INCLUDE\conio.h 20: struct text_info {
C:\TC\INCLUDE\conio.h 21: unsigned char winleft;
C:\TC\INCLUDE\conio.h 22: unsigned char wintop;
C:\TC\INCLUDE\conio.h 23: unsigned char winright;
C:\TC\INCLUDE\conio.h 24: unsigned char winbottom;
C:\TC\INCLUDE\conio.h 25: unsigned char attribute;
C:\TC\INCLUDE\conio.h 26: unsigned char normattr;
C:\TC\INCLUDE\conio.h 27: unsigned char currmode;
C:\TC\INCLUDE\conio.h 28: unsigned char screenheight;
C:\TC\INCLUDE\conio.h 29: unsigned char screenwidth;
C:\TC\INCLUDE\conio.h 30: unsigned char curx;
C:\TC\INCLUDE\conio.h 31: unsigned char cury;
C:\TC\INCLUDE\conio.h 32: };
C:\TC\INCLUDE\conio.h 33:
C:\TC\INCLUDE\conio.h 34: enum text_modes { LASTMODE=-1, BW40=0, C40, BW80, C80, MONO=7, C4350=64 };
C:\TC\INCLUDE\conio.h 35:
C:\TC\INCLUDE\conio.h 36:
C:\TC\INCLUDE\conio.h 37:
C:\TC\INCLUDE\conio.h 38:
C:\TC\INCLUDE\conio.h 39: enum COLORS {
C:\TC\INCLUDE\conio.h 40: BLACK,         
C:\TC\INCLUDE\conio.h 41: BLUE,
C:\TC\INCLUDE\conio.h 42: GREEN,
C:\TC\INCLUDE\conio.h 43: CYAN,
C:\TC\INCLUDE\conio.h 44: RED,
C:\TC\INCLUDE\conio.h 45: MAGENTA,
C:\TC\INCLUDE\conio.h 46: BROWN,
C:\TC\INCLUDE\conio.h 47: LIGHTGRAY,
C:\TC\INCLUDE\conio.h 48: DARKGRAY,      
C:\TC\INCLUDE\conio.h 49: LIGHTBLUE,
C:\TC\INCLUDE\conio.h 50: LIGHTGREEN,
C:\TC\INCLUDE\conio.h 51: LIGHTCYAN,
C:\TC\INCLUDE\conio.h 52: LIGHTRED,
C:\TC\INCLUDE\conio.h 53: LIGHTMAGENTA,
C:\TC\INCLUDE\conio.h 54: YELLOW,
C:\TC\INCLUDE\conio.h 55: WHITE
C:\TC\INCLUDE\conio.h 56: };
C:\TC\INCLUDE\conio.h 57:
C:\TC\INCLUDE\conio.h 58:
C:\TC\INCLUDE\conio.h 59:
C:\TC\INCLUDE\conio.h 60:
C:\TC\INCLUDE\conio.h 61: extern   int cdecl directvideo;
C:\TC\INCLUDE\conio.h 62: extern   int cdecl _wscroll;
C:\TC\INCLUDE\conio.h 63:
C:\TC\INCLUDE\conio.h 64:
C:\TC\INCLUDE\conio.h 65:
C:\TC\INCLUDE\conio.h 66:
C:\TC\INCLUDE\conio.h 67:
C:\TC\INCLUDE\conio.h 68: void        cdecl clreol( void );
C:\TC\INCLUDE\conio.h 69: void        cdecl clrscr( void );
C:\TC\INCLUDE\conio.h 70: void        cdecl gotoxy( int __x, int __y );
C:\TC\INCLUDE\conio.h 71: int         cdecl wherex( void );
C:\TC\INCLUDE\conio.h 72: int         cdecl wherey( void );
C:\TC\INCLUDE\conio.h 73: int         cdecl getch( void );
C:\TC\INCLUDE\conio.h 74: int         cdecl getche( void );
C:\TC\INCLUDE\conio.h 75: int         cdecl kbhit( void );
C:\TC\INCLUDE\conio.h 76: int         cdecl putch( int __c );
C:\TC\INCLUDE\conio.h 77:
C:\TC\INCLUDE\conio.h 78:
C:\TC\INCLUDE\conio.h 79: int         cdecl inp( unsigned __portid );
C:\TC\INCLUDE\conio.h 80: unsigned    cdecl inpw( unsigned __portid );
C:\TC\INCLUDE\conio.h 81: int         cdecl outp( unsigned __portid, int __value );
C:\TC\INCLUDE\conio.h 82: unsigned    cdecl outpw( unsigned __portid, unsigned __value );
C:\TC\INCLUDE\conio.h 83: unsigned char cdecl inportb( int __portid );
C:\TC\INCLUDE\conio.h 84: void        cdecl outportb( int __portid, unsigned char __value );
C:\TC\INCLUDE\conio.h 85:
C:\TC\INCLUDE\conio.h 86:
C:\TC\INCLUDE\conio.h 87: int         cdecl inport( int __portid );
C:\TC\INCLUDE\conio.h 88: void        cdecl outport( int __portid, int __value );
C:\TC\INCLUDE\conio.h 89:
C:\TC\INCLUDE\conio.h 90: void        cdecl delline( void );
C:\TC\INCLUDE\conio.h 91: int         cdecl gettext( int __left, int __top,
C:\TC\INCLUDE\conio.h 92: int __right, int __bottom,
C:\TC\INCLUDE\conio.h 93: void *__destin);
C:\TC\INCLUDE\conio.h 94: void        cdecl gettextinfo (struct text_info *__r );
C:\TC\INCLUDE\conio.h 95: void        cdecl highvideo( void );
C:\TC\INCLUDE\conio.h 96: void        cdecl insline( void );
C:\TC\INCLUDE\conio.h 97: void        cdecl lowvideo( void );
C:\TC\INCLUDE\conio.h 98: int         cdecl movetext( int __left, int __top,
C:\TC\INCLUDE\conio.h 99: int __right, int __bottom,
C:\TC\INCLUDE\conio.h 100: int __destleft, int __desttop );
C:\TC\INCLUDE\conio.h 101: void        cdecl normvideo( void );
C:\TC\INCLUDE\conio.h 102: int         cdecl puttext( int __left, int __top,
C:\TC\INCLUDE\conio.h 103: int __right, int __bottom,
C:\TC\INCLUDE\conio.h 104: void *__source );
C:\TC\INCLUDE\conio.h 105: void        cdecl textattr( int __newattr );
C:\TC\INCLUDE\conio.h 106: void        cdecl textbackground( int __newcolor );
C:\TC\INCLUDE\conio.h 107: void        cdecl textcolor( int __newcolor );
C:\TC\INCLUDE\conio.h 108: void        cdecl textmode( int __newmode );
C:\TC\INCLUDE\conio.h 109: void        cdecl window( int __left, int __top, int __right, int __bottom);
C:\TC\INCLUDE\conio.h 110:
C:\TC\INCLUDE\conio.h 111: void        cdecl _setcursortype( int __cur_t );
C:\TC\INCLUDE\conio.h 112: char * cdecl cgets( char *__str );
C:\TC\INCLUDE\conio.h 113: int         cdecl cprintf( const char *__format, ... );
C:\TC\INCLUDE\conio.h 114: int         cdecl cputs( const char *__str );
C:\TC\INCLUDE\conio.h 115: int         cdecl cscanf( const char *__format, ... );
C:\TC\INCLUDE\conio.h 116: char * cdecl getpass( const char *__prompt );
C:\TC\INCLUDE\conio.h 117: int         cdecl ungetch( int __ch );
C:\TC\INCLUDE\conio.h 118:
C:\TC\INCLUDE\conio.h 119:
C:\TC\INCLUDE\conio.h 120:
C:\TC\INCLUDE\conio.h 121:
C:\TC\INCLUDE\conio.h 122:
C:\TC\INCLUDE\conio.h 123:
C:\TC\INCLUDE\conio.h 124:
C:\TC\INCLUDE\conio.h 125: unsigned char cdecl    __inportb__( int __portid );
C:\TC\INCLUDE\conio.h 126: unsigned int cdecl     __inportw__( int __portid );
C:\TC\INCLUDE\conio.h 127: void        cdecl      __outportb__( int __portid, unsigned char __value );
C:\TC\INCLUDE\conio.h 128: void        cdecl      __outportw__( int __portid, unsigned int __value );
C:\TC\INCLUDE\conio.h 129:
C:\TC\INCLUDE\conio.h 130:
C:\TC\INCLUDE\conio.h 131:
C:\TC\INCLUDE\conio.h 132:
C:\TC\INCLUDE\conio.h 133:
C:\TC\INCLUDE\conio.h 134:
C:\TC\INCLUDE\conio.h 135:
C:\TC\INCLUDE\conio.h 136:
C:\TC\INCLUDE\conio.h 137:
C:\TC\INCLUDE\conio.h 138:
C:\TC\INCLUDE\conio.h 139:
C:\TC\INCLUDE\conio.h 140:
C:\TC\INCLUDE\conio.h 141:
C:\TC\INCLUDE\conio.h 142:
C:\TC\INCLUDE\conio.h 143:
C:\TC\INCLUDE\conio.h 144:
C:\TC\INCLUDE\conio.h 145:
C:\TC\INCLUDE\conio.h 146:
C:\TC\INCLUDE\conio.h 147:
C:\TC\INCLUDE\conio.h 148:
test.c 3: void main(){
test.c 4: clrscr();
test.c 5: printf("HOW large is this file?");
test.c 6: getch();
test.c 7: }
test.c 8:
test.c 9:

Note: During the compilation process compiler automatically deletes its intermediate file because size of intermediate is large.

We can also write absolute path of file which we want to include by using #include directive. In such case it will search only that path. If it is present then it will replace the include statement by the content of file. For example:

(a)
Step1: Write following c program and save it as myfile.c at the location: c:\tc\bin\raja

int x;
int max(int a,int b){
    return a>b?a:b;
}   

Step2: Compile myfile.c

Step3: Write the following c code:

#include<c:\tc\include\stdio.h>
#include<c:\tc\bin\raja\myfile.c>
int main(){
         x = max(20,40);
         printf("%d",x);
         return 0;
}
Step4: Save above c code any where you want then compile and execute the above code.

Output: 40

(b)
#include<c:\tc\bin\stdio.h>
int main(){
         printf("Hello world");
         return 0;
}
Output: Compilation error, unable to open the file stdio.h and conio.h

Form 2:
#include”filename”: This statement will first search the given file any current working directory and if it is not present then it will search include directory if it is also not present there then it will cause of compilation error, unable to open the file. If that file is present then include statement is replaced by content of file.


Example 1:
If file is present in the current working directory. Suppose my current working directory is c:\tc\bin

//c:\tc\bin\one.c
int a=5;
int b=10;

//c:\tc\bin\two.c
#include"stdio.h"
#include"one.c"
int main(){
    printf("a=%d  b=%d",a,b);
    return 0;
}

Output: a=5 b=10

Example 2:
If file is not present in the current working directory but it is present in include directory. Suppose my current working directory is c:\tc\bin

//c:\tc\include\one.c
int a=50;
int b=100;

//c:\tc\bin\two.c
#include<stdio.h>
#include"one.c"
int main(){
    printf("a=%d  b=%d",a,b);
    return 0;
}

Output: a=50 b=100

Example 3:
If file is present both in current working directory as well as include directory. Suppose my current working directory is c:\tc\bin

//c:\tc\bin\one.c
int a=5;
int b=10;

//c:\tc\bin\two.c
#include"stdio.h"
#include"one.c"
int main(){
    printf("a=%d  b=%d",a,b);
    return 0;
}

Output: a=5 b=10

Example 4:
If file is not present both in current working directory as well as include directory. Suppose my current working directory is c:\tc\bin

//c:\tc\bin\two.c
#include<stdio.h>
#include"one.c"
int main(){
    printf("a=%d  b=%d",a,b);
    return 0;
}

Output: Compilation error, unable to open one.c
If we will write absolute path of the file then it will search only at that location not in current working directory or include directory.

For example:
(a)

Step1: Write following c program and save it as myfile.c at the location: c:\tc\bin\raja

int x;
int max(int a,int b){
    return a>b?a:b;
}  

Step2: Compile myfile.c

Step3: Write the following c code:

#include"c:\tc\include\stdio.h"
#include"c:\tc\bin\raja\myfile.c"
int main(){
x=max(20,40);
    printf("%d",x);
    return 0;
}
Output: 40

Step4: Save above c code any where you want then compile and execute the above code.

(b)
#include"c:\tc\bin\stdio.h"
int main(){
    printf("Hello world");
    return 0;
}

Output: Compilation error, unable to open the file stdio.h and conio.h

2 comments: