
fabs

㭪            頥 ᮫⭮ 祭 ᫠  饩
                   窮.

⠪          #include<math.h>
                   double fabs(double x);

, ᮤঠ騩   math.h
⨯

ᠭ           fabs  ᮫⭮ 祭   頥
                     double.

頥       fabs 頥 ᮫⭮ 祭 .
祭

७ᨬ      fabs 㯭  UNIX  ন ⠭⮬
                   ANSI C.

 ⠪     abs, cabs, labs.

ਬ:

#include<stdio.h>
#include<math.h>

int main(void)
{
   float number = -1234.0;
   printf("᫮:%f, ᮫⭮ 祭 %f\n",number,fabs(number));
   return 0;
}


farcalloc

㭪            뤥    쭮 ᪮
                    .

⠪          #include<alloc.h>
                   void far * farcalloc(unsigned long nunits,
                                       unsigned long unitsz);

, ᮤঠ騩   alloc.h
⨯

ᠭ
                   㭪 farcalloc  ।   쭮
                   ᪮     ᨢ,  騩
                     nunits ⮢,  祬   
                   unitsz ⮢.

                    ।   쭮  ᪮
                      ᫥饥:

                   -     뤥      ந쭮
                     롮મ ().

                   -   뤥 , ࠧ஬  64.

                   -   㯠    뤥塞    ᯮ
                     "쭨" 㪠⥫ ( ਡ⮬ "far").

                       :  ,      ᢥ
                   ,  farcalloc ᮮ⢥ calloc,  
                   筠.      ᯮ  ࠬ  ⨯  long
                   unsigned,   ६,   㭪樨 (ਬ
                   malloc) ᯮ ࠬ ⨯ unsigned.

                         tiny    㭪  ᯮ짮
                   .

頥       㭪 farcalloc 頥 㪠⥫
祭             ,  NULL, ᫨  ࠧ饭 
                     墠⨫ .

७ᨬ      㭪 㭨쭠  ⥬ DOS.

 ⠪     calloc, farcoreleft, farfree, farmalloc, malloc.

ਬ:

#include<stdio.h>
#include<alloc.h>
#include<string.h>
#include<dos.h>

int main(void)
{
   char far *fptr;
   char *str = "Hello";
                   
   /* 뤥  */
   fptr = farcalloc(10,sizeof(char));
   if(fptr)
   {
      /* ᪮஢ ப "Hello"  뤥  . */
      /* 砭. ᯮ 㭪 movedata, ᪮ 
                     ࠡ   (small)  ,
                     ன  ᯮ짮 㭪樨 ஢-
                     ப,  ࠧ㬥,  -
                      ⨯ near */
      movedata(FP_SEG(str),FP_OFF(str),FP_SEG(fptr),FP_OFF(fptr),
               strlen(str));
      /* 뢥 ப.    䨪 F*/
      printf(" ப  㪠⥫ far: %Fs\n",fptr);
      /* ᢮  */
      farfree(fptr);
   }
   return 0;
}


farcoreleft

㭪            頥 ꥬ ᯮ㥬   쭮
                   ᪮  .

⠪          #include<alloc.h>
                   unsigned long farcoreleft(void);

, ᮤঠ騩   alloc.h
⨯

ᠭ           㭪 farcoreleft    頥    騩    ꥬ
                   ᯮ㥬      ,  饩   
                   ᫥ 뤥 .

                        tiny    㭪   ᯮ짮
                   .

頥       farcoreleft 頥 ꥬ ᯮ㥬 
祭            ᠬ 孨 뤥   殬 .

७ᨬ      farcoreleft 㭨쭠        DOS.   㭪   
                   ᮢ⨬  Windows.

 ⠪     coreleft, farcalloc, farmalloc.

ਬ:

#include<stdio.h>
#include<alloc.h>

int main(void)
{
   printf("ꥬ ᯮ㥬   쭥 \n");
   printf("ࠢ %lu  \n",farcoreleft());
   return 0;
}


farfree

㭪            ᢮ ,     뤥        쭮
                   ᪮  .

⠪          #include<alloc.h>
                   void farfree(void far * block);

, ᮤঠ騩   alloc.h
⨯

ᠭ           㭪 farfree     ᢮      ।⥫쭮
                   뤥  쭮 ᪮  
                   .

                         tiny    㭪  ᯮ짮
                   .

                      small  medium  ,  뤥
                   farmalloc,      ᢮  㭪樥  free  
                   ,  ..          쭠   
                   쭠   ࠧ.

頥       .
祭

७ᨬ      farfree 㭨쭠  DOS.

 ⠪     farcalloc, farmalloc.

ਬ:

#include<stdio.h>
#include<alloc.h>
#include<string.h>
#include<dos.h>

int main(void)
{
   char far *fptr;
   char *str = "Hello";
   /* 뤥  */
   fptr = farcalloc(10,sizeof(char));
                   
      /* ᪮஢ ப "Hello"  뤥  . */
      /* 砭. ᯮ 㭪 movedata, ᪮ 
                     ࠡ   (small)  ,
                     ன  ᯮ짮 㭪樨 ஢-
                     ப,  ࠧ㬥,  -
                      ⨯ near */
                   
      movedata(FP_SEG(str),FP_OFF(str),FP_SEG(fptr),FP_OFF(fptr),
               strlen(str));
                   
      /* 뢥 ப.    䨪 F*/
      printf(" ப  㪠⥫ far: %Fs\n",fptr);
                   
      /* ᢮  */
   farfree(fptr);
   return 0;
}


farheapcheck

㭪            ᬠਢ  ஢  
                    .

⠪          #include<alloc.h>
                   int farheapcheck(void);

, ᮤঠ騩   alloc.h
⨯

ᠭ
                   farheapcheck 室    쭮  ᪮
                       ஢    ,  㪠⥫,
                   ࠧ  㣨  ࠬ.

饬         訡  祭 < 0,  ᯥ譮
祭           襭 頥 祭 > 0.

                   ᫨  쭮 ᪮  , 
                   頥    祭   _HEAPEMPTY   (1).
                   
                   ᫨        heap       ஢७,       
                   頥_HEAPOK (2).
                   
                   ᫨      祭,           頥
                   _HEAPCORRUPT (-1).

७ᨬ      farheapcheck 㭨쭠      DOS.   㭪    
                   ᮢ⨬  Windows.

 ⠪     heapcheck.

ਬ:

#include<stdio.h>
#include<alloc.h>

#define NUM_PTRS    10
#define NUM_BYTES   16

int main(void)
{
   char far *array[NUM_PTRS];
   int i;
   for(i=0; i<NUM_PTRS; i++)
     array[i] = farmalloc(NUM_BYTES);
   for(i=0; i<NUM_PTRS; i+=2)
     farfree(array[i]);
   if(farheapcheck() == _HEAPCORRUPT)
     printf("  祭\n");
   else
     printf(" ଠ쭮\n");
   return 0;
}


farheapcheckfree

㭪            ஢ ᢮   쭮 ᪮
                      ⭮ 祭.

⠪          #include<alloc.h>
                   int farheapcheckfree(unsigned int fillvalue);

, ᮤঠ騩   alloc.h
⨯

ᠭ           ????????????????

饬         訡  祭 < 0,  ᯥ譮
祭           襭 頥 祭 > 0.

                   ᫨  쭮 ᪮  , 
                   頥 祭 _HEAPEMPTY (1).
                   
                   ᫨    heap  ஢७,    頥
                   _HEAPOK (2).
                   
                   ᫨      祭,           頥
                   _HEAPCORRUPT(-1).
                   
                   ᫨ 祭  ⫨砥  fillvalue, 
                   頥 _BADVALUE (-3).

७ᨬ      farheapcheckfree 㭨쭠     DOS.  㭪  
                   ᮢ⨬  Windows.

 ⠪     farheapfillfree, heapcheckfree.

ਬ:

#include<mem.h>
#include<stdio.h>
#include<alloc.h>

#define NUM_PTRS    10
#define NUM_BYTES   16

int main(void)
{
   char far *array[NUM_PTRS];
   int i;
   int j;
   int res;
   for(i=0; i<NUM_PTRS; i++)
     if((array[i] = farmalloc(NUM_BYTES))==NULL)
        {
         printf(" 墠⠥ \n");
         return 1;
        }
   for(i=0; i<NUM_PTRS; i+=2)
     farfree(array[i]);
   if(farheapfillfree(1) < 0)
   {
     printf("  祭\n");
     return 1;
   }
   for(i=0; i<NUM_PTRS; i+=2)
     for(j=0; j<NUM_BYTES; j++)
        array[i][j]=0;
   res = farheapcheckfree(1);
   if(res<0)
      switch(res)
      {
      case _HEAPCORRUPT:
           printf("  祭\n");
           return 1;
      case _BADVALUE:
           printf("୮ ᮤন ⮩  \n");
           return 1;
      default:
           printf(" ᯮ 訡\n");
           return 1;
      }
   printf(" ଠ쭮\n");
   return 0;
}


farheapchecknode

㭪                ஢   ⤥   㧥    쭮
                   ᪮  .

⠪          #include<alloc.h>
                   int farheapchecknode(void *node);

, ᮤঠ騩   alloc.h
⨯

ᠭ
                   ᫨ 㧥      ᢮      farheapchecknode
                   뢠  㪠⥫  ᢮  㧥,  
                   farheapchecknode     祭 _BADNODE,
                    । _FREEENTRY.    ந室
                   ⮬,    ᥤ  ᢮  ᫨ 
                   ,  㪠    맮  㭪樨,    
                   .

饬         訡  祭 < 0,  ᯥ譮
祭           襭 頥 祭 > 0.

                   ᫨  쭮 ᪮  , 
                   頥 祭 _HEAPEMPTY (1).
                   
                   ᫨       祭,          頥
                   _HEAPCORRUPT(-1).
                   
                   ᫨ 㧥  ,  頥 _BADNODE (-2).
                   
                   ᫨ 㧥 ᢮,    頥  _FREEENTRY
                   (3).
                   
                   ᫨ 㧥,   ᯮ㥬 ,   頥
                   _USEDENTRY (4).

७ᨬ      farheapcheckfree 㭨쭠     DOS.  㭪  
                   ᮢ⨬  Windows.

 ⠪     heapchecknode.

ਬ:

#include<stdio.h>
#include<alloc.h>

#define NUM_PTRS    10
#define NUM_BYTES   16

int main(void)
{
   char far *array[NUM_PTRS];
   int i;
   for(i=0; i<NUM_PTRS; i++)
     array[i] = farmalloc(NUM_BYTES);
   for(i=0; i<NUM_PTRS; i+=2)
     farfree(array[i]);
   for(i=0; i<NUM_PTRS; i++)
   {
      printf(" %2d",i);
      switch(farheapchecknode(array[i]))
      {
         case _HEAPEMPTY:
             printf("  \n");
             break;
         case HEAPCORRUPT:
             printf("  祭\n");
             break;
         case _BADNODE:
             printf("  㧥\n");
             break;
         case _FREEENTRY:
             printf("  \n");
             break;
         case _USEDENTRY:
             printf("  \n");
             break;
         default:
             printf(" ⭮ 頥 祭\n");
             break;
     }
  }
  return 0;
}


farheapfillfree

㭪             ᢮    쭮 ᪮
                     ⠭ 祭.

⠪          #include<alloc.h>
                   int farheapfillfree(unsigned int fillvalue);

, ᮤঠ騩   alloc.h
⨯

ᠭ           ????????????????

饬         訡  祭 < 0,  ᯥ譮
祭           襭 頥 祭 > 0.

                   ᫨  쭮 ᪮  , 
                   頥 祭 _HEAPEMPTY (1).
                   
                   ᫨    heap  ஢७,    頥
                   _HEAPOK (2).
                   
                   ᫨      祭,           頥
                   _HEAPCORRUPT(-1).

७ᨬ      farheapfillfree 㭨쭠    DOS.   㭪   
                   ᮢ⨬  Windows.

 ⠪     farheapcheckfree, heapfillfree

ਬ:

#include<mem.h>
#include<stdio.h>
#include<alloc.h>

#define NUM_PTRS    10
#define NUM_BYTES   16

int main(void)
{
   char far *array[NUM_PTRS];
   int i,j;
   int res;
   for(i=0; i<NUM_PTRS; i++)
     (array[i] = farmalloc(NUM_BYTES);
   for(i=0; i<NUM_PTRS; i+=2)
     farfree(array[i]);
   if(heapfillfree(1) < 0)
   {
     printf("  祭\n");
     return 1;
   }
   for(i=0; i<NUM_PTRS; i+=2)
     for(j=0; j<NUM_BYTES; j++)
        array[i][j]=0;
   res = farheapcheckfree(1);
   if(res<0)
      switch(res)
      {
      case _HEAPCORRUPT:
           printf("  祭\n");
           return 1;
      case _BADVALUE:
           printf("୮ ᮤন ⮩  \n");
           return 1;
      default:
           printf(" ᯮ 訡\n");
           return 1;
      }
   printf(" ଠ쭮\n");
   return 0;
}


farheapwalk

㭪            ᯮ  ६饭  쭮 heap
                    㧫  㧫.

⠪          #include<alloc.h>
                   int farheapwalk(struct farheapinfo *hi);

, ᮤঠ騩   alloc.h
⨯

ᠭ           farheapwalk ࠧ㬥,    祭.
                     ஢ન  ।  ᯮ짮   farheapwalk,
                   맮  farheapcheck.    ⨦ ᫥
                    㭪  頥  _HEAPOK.    ᫥饬
                   맮 farheapwalk,  ୥ _HEAPEND.

                   farheapwalk 砥 㪠⥫      ⨯
                   heapinfo  (।  䠩 alloc.h).   ࢮ
                   맮 farheapwalk  ⠭    hi.ptr    0.
                   farheapwalk  ୥     ⮬   ࢮ
                     heap .   hi.size ᮤন  ࠧ
                   ⮣   . hi.in_use -  䫠, 
                   ⠭,  ᫨      ᯮ  
                   騩 .

饬        ᫨  쭮 ᪮  , 
祭           頥 祭 _HEAPEMPTY (1).
                   
                   ᫨  heapinfo ᮤন  ,  
                   頥 _HEAPOK (2).
                   
                   ᫨ ⨣   heap ,   頥
                   _HEAPEND (5).

७ᨬ      farheapwalk 㭨쭠        DOS.   㭪   
                   ᮢ⨬  Windows.

 ⠪     heapwalk.

ਬ:

#include<stdio.h>
#include<alloc.h>

#define NUM_PTRS    10
#define NUM_BYTES   16

int main(void)
{
   struct farheapinfo hi;
   char far *array[NUM_PTRS];
   int i;
   for(i=0; i<NUM_PTRS; i++)
     array[i] = farmalloc(NUM_BYTES);
   for(i=0; i<NUM_PTRS; i+=2)
     farfree(array[i]);
   hi.ptr = NULL;
   printf("            \n");
   printf("   ------      ------   \n");
   while(farheapwalk(&hi) == _HEAROK)
      if(hi.in_use)
          printf("%7u     ᯮ\n",hi.size);
      else
          printf("%7u     ᢮\n",hi.size);
   return 0;
}


farmalloc

㭪            頥    쭮 ᪮ 
                   .

⠪          #include<alloc.h>
                   void far * farmalloc(unsigned long nbytes);

, ᮤঠ騩   alloc.h
⨯

ᠭ
                   㭪 farmalloc  뤥         쭮
                   ᪮  ,  ࠧ   
                   ।  㬥 nbytes.

                    뤥  쭮 ᪮ 
                       ᫥饥:

                   -     뤥      ந쭮
                     롮મ ().

                   -   뤥 , ࠧ஬  64.

                   -   㯠    뤥塞    ᯮ
                     "쭨" 㪠⥫ ( ਡ⮬ "far").

                       :  ,      ᢥ
                   ,   㭪   ᮮ⢥,        
                   筠,  malloc.  砥 ࠬ ⨯ long
                   unsigned,      ६,     malloc   ᯮ
                   ࠬ ⨯ unsigned.

                         tiny    㭪  ᯮ짮
                   .

頥       㭪 farmalloc 頥 㪠⥫ 
祭            뤥   , ᫨  ࠧ饭
                      墠⨫ .

७ᨬ      㭪 㭨쭠  ⥬ DOS.

 ⠪     farcalloc, farcoreleft, farfree, farrealloc, malloc.

ਬ:

#include<stdio.h>
#include<alloc.h>
#include<string.h>
#include<dos.h>

int main(void)
{
   char far *fptr;
   char *str = "Hello";
   /* 뤥  */
   fptr = farmalloc(10);
                   
      /* ᪮஢ ப "Hello"  뤥  . */
      /* 砭: ᯮ 㭪 movedata, ᪮ 
                     ࠡ   (small)  ,
                     ன  ᯮ짮 㭪樨 ஢-
                     ப,  ࠧ㬥,  -
                      ⨯ near */
                   
      movedata(FP_SEG(str),FP_OFF(str),FP_SEG(fptr),FP_OFF(fptr),
               strlen(str));
                   
      /* 뢥 ப.    䨪 F*/
      printf(" ப  㪠⥫ far: %Fs\n",fptr);
                   
      /* ᢮  */
   farfree(fptr);
   return 0;
}


farrealloc

㭪             ࠧ 뤥   쭮
                   ᪮  .

⠪          #include<alloc.h>
                   void far * farrealloc(void far * oldblock,
                                         unsigned long nbytes);

, ᮤঠ騩   alloc.h
⨯

ᠭ           㭪 farrealloc     ࠧ   뤥
                   ࠭  ,   室 ᮤন ண
                      .

                    ।  쭮  ᪮ 
                     ᫥饥:

                   -   뤥        ந쭮
                     롮મ ().

                   -   뤥 , ࠧ஬  64.

                   -   㯠    뤥塞    ᯮ
                     "쭨" 㪠⥫ ( ਡ⮬ "far").

                        tiny    㭪   ᯮ짮
                   .

頥       㭪 farrealloc 頥 㪠⥫ 
祭            뤥 ,   ⫨
                    室.  ᫨   ࠧ饭   
                   墠⨫ ,   㭪  farrealloc  頥
                   NULL.

७ᨬ      㭪 㭨쭠  ⥬ DOS.

 ⠪     farmalloc, realloc.

ਬ:

#include<stdio.h>
#include<alloc.h>

int main(void)
{
   char far *fptr;
   fptr = farmalloc(10);
   printf(" ࢮ :%Fp\n",fptr);
   fptr = farrealloc(20);
   printf(" ண :%Fp\n",fptr);
   farfree(fptr);
   return 0;
}


fclose

㭪            뢠 ⮪.

⠪          #include <stdio.h>
                   int fclose (FILE * stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 fclose  뢠  㪠  ⮪ stream.
                     ,  易    ⮪  stream,  ।
                   ⨥    뢠.    ,   ࠧ饭
                   ⥬, ᢮  ६  .
                   ,  祭  㭪ﬨ setbuf  setvbuf,
                    ᢮  ⮬᪨.  (,  ᫨  
                   ⢥ 㪠⥫,  㭪樨 setvbuf । 0, 
                    㤥 ᢮  ⨨ ⮪.)

頥       㭪 fclose  ᯥ譮 襭 頥
祭           0. ᫨ 뫨 㦥 - 訡, 㭪
                   fclose 頥 祭 EOF.

७ᨬ       㭪 ন ⥬ UNIX  ⠭-
                   ⮬ ANSI C.

 ⠪     close, fcloseall, fdopen, fflush, fflashall, fopen,
                   freopen.

ਬ:

#include<string.h>
#include<stdio.h>

int main(void)
{
   FILE *fp;
   char buf[11] = "0123456789";
   /* ᮧ 䠩 ᮤঠ騩 10  */
   fp = fopen("DUMMY.FIL","w");
   if(fp)
   {
       fwrite(&buf,strlen(buf),1,fp);
       /*  䠩 */
       fclose(fp);
   }
   else
   {
       printf("訡,  ⨨ 䠩\n");
   }
   return 0;
}


fcloseall

㭪            뢠  ⮪.

⠪          #include<stdio.h>
                   int fcloseall(void);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 fcloseall 뢠   ⮪,
                   ᪫ stdin  stdout, stdprn, stdaux  strerr.

頥       fcloseall 頥 ᫮  ⮪. 
祭            訡 頥 EOF.

७ᨬ      ন ⥬ UNIX.

 ⠪     fclose, fdopen, flushall, fopen, freopen.

ਬ:

#include<stdio.h>

int main(void)
{
   FILE *fp1,*fp2;
   int streams_closed;
   /*   ⮪ */
   fp1 = fopen("DUMMY.ONE","w");
   fp2 = fopen("DUMMY.TWO","w");
   /*   ⮪ */
   streams_closed = fcloseall();
   if(streams_closed == EOF)
      /* 뢥 ᮮ饭  訡 */
      perror(" 訡 ");
   else
      /* 뢥 १ ࠡ 㭪樨 */
      printf("뫮  %d ⮪\n",streams_closed);
   return 0;
}


fcvt

㭪            ८ࠧ ᫮    饩  窮     ப
                   ᨬ.

⠪          #include<stdlib.h>
                   char * fcvt(double value, int ndig, int * dec,
                   int * sign);

, ᮤঠ騩   stdlib.h
⨯

ᠭ           㭪 fcvt ८ࠧ 祭 value  ப  
                   㫥  砭   ndig ,  稭  ᠬ
                     饩  ,      頥   
                   㪠⥫    ப.      筮   窨
                   ⭮⥫쭮  砫   ப   ᢥ   ࠧ
                   ࠭    ࠬ  dec (⥫쭮 祭
                   decpt 砥     祭  ).  
                   ᠬ   ப  筮  窨  .  ᫨  
                   १   ⥫,   ᫮,      ஥
                   㪠뢠  㪠⥫ sign,   㫥
                   祭,    ࠢ 0.
                   
                   ᫮ 㣫      ࠧ冷,  
                   ࠬ஬ ndig.

頥       㭪 fcvt 頥  㪠⥫
祭            ப,  ᮤন १뢠
                     맮 㭪権.

७ᨬ      㭪 ন    ⥬  UNIX.   
                   ।  ⠭ ANSI  C,    ⮬    
                   ४㥬    ᯮ짮          ᠭ
                   ७ᨬ ணࠬ.

 ⠪     ecvt, gcvt, sprintf.

ਬ:

#include<stdlib.h>
#include<stdio.h>

int main(void)
{
   char *str;
   double num;
   int dec, sign;
   int ndig = 5;

   num = 9.876;
   str = fcvt(num,ndig,&dec,&sign);
   printf("ப = %s      dec = %d sign = %d\n",string,dec,sign);
   /* ⥫쭮 ᫮ */
   num = -123.45;
   str = fcvt(num,ndig,&dec,&sign);
   printf("ப = %s      dec = %d sign = %d\n",string,dec,sign);
   num = 0.678e5;
   str = fcvt(num,ndig,&dec,&sign);
   printf("ப = %s      dec = %d sign = %d\n",string,dec,sign);
   return 0;
}


fdopen

㭪            뢠 ⮪  ᪨ ஬ 䠩.

⠪          #include<stdio.h>
                   FILE * fdopen(int handle, char * type);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 fdopen  뢠  ⮪     ਯ஬,
                   祭 㭪ﬨ creat, dup, dup2  open. 
                   ⮪  ᮢ  ०,    ஬  
                    handle.

                   쭠 ப  type        ᫥
                   祭:

                   r - ⨥ 䠩 ⮫쪮  ⥭.

                   w -  䠩  .

                    - ᮥ; ⨥    
                       䠩  ᮧ  , ᫨ 䠩 
                       .

                   r+ - ⨥ 饣 䠩  
                        (⥭  ).

                   w+ -   䠩  .

                   a+ - ⨥  ᮥ; ⨥ (
                        ᮧ, ᫨   䠩      )   
                           䠩.

                   ᫨   䠩  뢠     ᮧ   
                   ⥪⮢  ०,     ਯ ᨬ t 
                   祭  ࠬ  type  (rt,   w+t,      ..);
                   筮,    ᯥ䨪樨  ୮ ० 
                     祭 ࠬ type  ᨬ  b
                   (wb,a+b,  ..).

                   ᫨   ࠬ type  ᨬ t  b,
                   ०  㤥  ।  쭮   ६
                   _fmode.   ᫨  ६  _fmode    祭
                   O_BINARY,  䠩    뢠      ୮
                   ०,  ,  ᫨ _fmode  祭 O_TEXT,
                   䠩  뢠    ⥪⮢   ०.   
                   ⠭ O_... ।  䠩 fcntl.h.

                    ⨨  䠩    ०  (UPDATE),
                     १騬  ⮪  stream      
                   믮  樨 ,  ⠪  뢮.  
                    뢮   ᫥  ।⢥  
                      ⥫⢠ 㭪権 fseek  rewind.
                    ,  ਬ 㭪権 fseek, rewind 
                     ।⢥  ᫥    뢮  
                   ,  砥  䠩 (EOF).

頥        ᯥ譮 襭 fdopen  頥
祭             ⮪ stream.  砥 訡,
                   㭪   (NULL).

७ᨬ      fdopen নe  ⥬ UNIX.

 ⠪     㭪樨  fclose, freopen, fopen, opene.

ਬ:

#include<sys\stat.h>
#include <stdio.h>
#include <fcntl.h>
#include<io.h>

int main(void)
{
   int handle;
   FILE *stream;

   /*  䠩 */
   handle = open("DUMMY.FIL", O_CREAT, S_IREAD|S_IWRITE);

   /* ⥯ ८ࠧ㥬   ⮪ */
   stream = fdopen(handle, "w");
   if (stream == NULL)
      printf("訡 fdopen\n");
   else {
      fprintf(stream, "Hello, world\n");
      fclose(stream);
   }
   return 0;
}


feof

㭪            㦨  䠩 (EOF)  ⮪.

⠪          #include<stdio.h>
                   int feof(FILE * stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 feof      ப,    
                   ந   ஢     ⮪  stream  
                   ਧ  䠩  (EOF).  ᫨  ਧ  稫
                   祭    ࠧ,  樨 ⥭ 䠩
                   ࠭  祭   ,      㤥
                   맢 㭪 rewind  䠩  㤥 .

                   ਧ    䠩   뢠      
                   樨 .

頥
祭           㭪 feof 頥 㫥 祭, ᫨
                    ᫥  樨    ⮪  stream  
                   㦥  䠩,  0  ⨢ 砥.

७ᨬ      feof 㯭  ⥬ UNIX  ন
                   ⠭⮬ ANSI C.

 ⠪     clearerr, eof, ferror, perror.

ਬ:

#include <stdio.h>

int main(void)
{
   FILE *stream;
   char ch;

   /*  䠩  ⥭ */
   stream = fopen("DUMMY.FIL", "r");
   /*   䠩 ᨬ */
   ch = fgetc(stream);
   /*  䠩? */
   if(feof(stream))
      printf(" 䠩\n");
   /*  䠩 */
   fclose(stream);
   return 0;
}


ferror

㭪            㦨 訡  ⮪.

⠪          #include<stdio.h>
                   int ferror(FILE * stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 ferror     ப,   
                   ஢  ⮪ stream  訡 
                     ⥭.  ᫨ ⠭ ਧ  訡
                   ⮪  stream,   ࠭   맮 㭪権
                   clearerr  rewind     ⮪.

頥       㭪 ferror 頥 㫥 祭, ᫨
祭            ⮪ stream 뫠 㦥 訡.

७ᨬ       㭪 ন  ⥬ UNIX 
                   ᮢ⨬  ⠭⮬ ANSI C.

 ⠪     clearerr, eof, feof, fopen, gets, perror.

ਬ:

#include <stdio.h>

int main(void)
{
   FILE *stream;
   char ch;

   /*  䠩   */
   stream = fopen("DUMMY.FIL", "w");
   /* ࠢ஢ 訡 */
   ch = fgetc(stream);
   /*  䠩? */
   if(ferror(stream))
   {
      /* 뢥 ᮮ饭  訡 */
      printf("訡 ⥭\n");
      /*  ਧ 訡 */
      clearerr(stream);
   }
   fclose(stream);
   return 0;
}


fflush

㭪            뢠 ⮪.

⠪          #include<stdio.h>
                   int fflush(FILE * stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 fflush 뢠  䠩 ᮤন ,
                   易  ⮪ stream,  ᫨    
                   뢮.

                   fflush   뢠  ﭨ    ਧ
                   ⮪.

頥        砥 ᯥ譮 襭 頥 0. 
祭           訡 頥 EOF.

७ᨬ      ন ⠭⮬ ANSI C  ᮢ⨬ 
                   UNIX.

 ⠪     fclose, flushall, setbuf, setvbuf.

ਬ:

#include<string.h>
#include<stdio.h>
#include<conio.h>
#include<io.h>

void flush(FILE *stream);

int main(void)
{
   FILE *stream;
   char msg[] = "⮢ ਬ";
   /* ᮧ 䠩 */
   stream = fopen("DUMMY.FIL","w");
   /*   䠩  */
   fwrite(msg,strlen(msg),1,stream);
   clrscr();
   printf("  ⮪    ...\n");
   getch();
   /*    䠩,    */
   flush(stream);
   printf("ন ஢ 襭  䠩\n");
   printf(" 襭   \n");
   getch();
   return 0;
}
void flush(FILE *stream)
{
   int duphandle;
   /*  ७  䠩 */
   fflash(stream);
   /* ᮧ ன ਯ */
   duphandle = dup(fileno(stream));
   /*  ன ਯ   ஢ DOS */
   close(duphandle);
}


fgetc

㭪            砥 ᨬ  ⮪.

⠪          #include<stdio.h>
                   int fgetc(FILE * stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           fgetc 頥  ᫥騩  ᨬ    㪠
                   室 ⮪ stream.

頥        ᯥ譮 襭 頥 ᨬ, ८-
祭           ࠧ  ⨯ int  ७ . 
                   㦥  䠩 頥 EOF.

७ᨬ      ন ⠭⮬ ANSI C  ᮢ⨬ 
                   UNIX.

 ⠪     fgetchar, fputc, getc, getch, getchar, getche,
                   ungetc, ungetch.

ਬ:

#include<string.h>
#include<stdio.h>
#include<conio.h>

int main(void)
{
   FILE *stream;
   char msg[] = "⮢ ਬ";
   char ch;
   /* ᮧ 䠩    */
   stream = fopen("DUMMY.FIL","w+");
   /*   䠩  */
   fwrite(msg,strlen(msg),1,stream);
   /* ३  砫 䠩 */
   fseek(stream,0,SEEK_SET);
   do
   {
      /*  ᨬ  䠩 */
      ch = fgetc(stream);
      /* 뢥 ᨬ  ࠭ */
      putch(ch);
   } while(ch!=EOF);
   fclose(stream);
   return 0;
}


fgetchar

㭪            砥 ᨬ  ⮪ stdin.

⠪          #include<stdio.h>
                   int fgetchar(void);

, ᮤঠ騩   stdio.h
⨯

ᠭ           fgetchar 頥 ᫥騩 ᨬ  ⮪
                   stdin. ।  fgetc(stdin).

頥        ᯥ譮 襭 頥 ᨬ, ८-
祭           ࠧ  ⨯ int  ७ . 
                   㦥  䠩  訡 頥 EOF.

७ᨬ      ন UNIX.

 ⠪     fgetc, fputchar, getchar.

ਬ:

#include<stdio.h>

int main(void)
{
   char ch;
   /*   */
   printf(" ᨬ, ⥬  <Enter>.\n");
   /*  ᨬ  ⮪ stdin */
   ch = fgetchar();
   /*   ᨬ */
   printf(" ⠭ ᨬ: '%c'\n",ch);
   return 0;
}


fgetpos

㭪            頥  㪠⥫  ⥪饩  樨  
                   䠩.

⠪          #include<stdio.h>
                   int fgetpos(FILE * stream, fpos_t *pos);

, ᮤঠ騩   stdio.h
⨯

ᠭ           fgetpos ࠭        㪠⥫    䠩,
                   易  ⮪ stream,   ,  㪠뢠
                   pos. 筮 祭  "襡 㫮窮",
                   㣨 ᫮,      祭.

                    fpos_t 뢠 ᫥騬 ࠧ:

                        typedef long fpos_t;

頥        ᯥ譮 襭 fgetpos 頥 0. 
祭           訡 頥      㫥     祭     
                   ⠭ errno  EBADF  EINVAL.

७ᨬ      ন ⠭⮬ ANSI C.

 ⠪     fseek, fsetpos, ftell, tell.

ਬ:

#include<string.h>
#include<stdio.h>

int main(void)
{
   FILE *stream;
   char string[] = "⮢ ਬ";
   fpos_t filepos;
   /* ᮧ 䠩    */
   stream = fopen("DUMMY.FIL","w+");
   /*   䠩  */
   fwrite(string,strlen(string),1,stream);
   /* ᮮ  㪠⥫ */
   fgetpos(stream,&filepos);
   printf("⥫ 室  %ld 樨\n");
   fclose(stream);
   return 0;
}


fgets

㭪            砥 ப ᨬ  ⮪.

⠪          #include<stdio.h>
                   char * fgets(char s, int n, FILE *stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           fgets 뢠  ⮪ stream ப ᨬ  
                   頥    s.   蠥 ᫥  n-1
                   ᨬ    ᨬ 室  ᫥
                   ப,  ᬮ  ந ࠭.  ⫨稥 
                   gets,  fgets ४頥  ப    祭
                   ᨬ 室  ᫥ ப.  㫥 
                      ப  樨  .

頥        ᯥ譮 襭 頥 㪠⥫  s,
祭            訡   䠩 頥 NULL.

७ᨬ      ⨬    ⥬   UNIX      ন
                   ⠭⮬  ANSI  C.  ।  ⠪      
                   ୨  .

 ⠪     cgets, fputs, gets.

ਬ:

#include<string.h>
#include<stdio.h>

int main(void)
{
   FILE *stream;
   char string[] = "⮢ ਬ";
   char msg[20];
   /* ᮧ 䠩    */
   stream = fopen("DUMMY.FIL","w+");
   /*   䠩  */
   fwrite(string,strlen(string),1,stream);
   /* ३  砫 䠩 */
   fseek(stream,0,SEEK_SET);
   /*  ப  䠩 */
   fgets(msg,strlen(string)+1,stream);
   /*  ப */
   printf("%s",msg);
   fclose(stream);
   return 0;
}


filelength

㭪            砥 ࠧ 䠩  .

⠪          #include<io.h>
                   long filelength(int handle);

, ᮤঠ騩   io.h
⨯

ᠭ           㭪 filelength 頥    䠩,
                   ᮮ⢥饣 ਯ handle.

頥        ᯥ譮 襭 㭪 filelength
祭           頥 祭  ⨯  long -    䠩   
                   .  訡 㭪 頥 祭 -1L,
                    쭮 ६ errno ᢠ:

                      EBADF -   䠩.

७ᨬ      filelength 㭨쭠  DOS.

 ⠪     fopen, lseek, open.

ਬ:

#include<stdio.h>
#include<io.h>
#include<fcntl.h>
#include<sys\stat.h>
#include<string.h>

int main(void)
{
   int handle;
   char buf[11] = "0123456789";
   /* ᮧ 䠩  10  */
   handle = open("DUMMY.FIL",O_RDWR|O_CREAT|O_TRUNC,S_IREAD|S_IWRITE);
   write(handle,buf,strlen(buf));
   /*  ࠧ 䠩 */
   printf(" 䠩   : %ld\n",filelength(handle));
   /*  䠩 */
   close(handle);
   return 0;
}


fileno

㭪            砥 ਯ 䠩.

⠪          #include<stdio.h>
                   int fileno(FILE * stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           fileno ।⠢   ᮡ  ப,  
                   頥 ᪨    䠩    
                   ⮪ stream. ᫨ ⮪ stream   
                   ,   㭪    fileno    頥    ,
                   祭  ⮪  ࢮ ⨨.

頥       fileno 頥 楫 ᫮, 饥
祭           ਯ 䠩, ᮮ⢥騩 ⮪ stream.

७ᨬ       㭪 ন  ⥬ UNIX.

 ⠪     fdopen, fopen, freopen.

ਬ:

#include<stdio.h>

int main(void)
{
   FILE *stream;
   int handle;
   /* ᮧ 䠩 */
   stream = fopen("DUMMY.FIL","w");
   /*  ਯ 䠩 */
   handle = fileno(stream);
   /*   */
   printf("ਯ 䠩 = %d\n",handle);
   /*  䠩 */
   fclose(stream);
   return 0;
}


fillellipse

㭪              訢 .

⠪          #include <graphics.h>
                   void far ellipse(int x,int y,int xradius,
                                     int yradius);

, ᮤঠ騩   graphics.h
⨯

ᠭ                  業஬      窥   (x,y)   
                   ਧ⠫쭮    ⨪쭮  ﬨ  xradius   
                   yradius ᮮ⢥⢥,   訢  ⥪騬
                   梥⮬ ᪨, ᯮ ⥪騩 蠡.

頥       .
祭

७ᨬ      㭪 㭨쭠  Borland C++.  ࠡ⠥
                   ⮫쪮    IBM PC  ᮢ⨬  ,
                   ᭠饭 ᯫ묨 ࠬ,  ন騬
                   ᪨ ०. 㭪  ᮢ⨬  Windows.

 ⠪     arc, circle, ellipse, getaspectratio, pieslices,
                   setaspectraio.

ਬ:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/*  ⮮। */
int graphdriver = DETECT, gmode, errorcode;
int midx,midy,i;
int xradius = 100,yradius = 50;

/* 樠 䨪   ६ */
initgraph(&graphdriver,&gmode,"");

/* 祭 १ 樠樨 */
errorcode = graphresult();
if(errorcode != grOk)  /* ᫨ 訡 */
{
   printf("訡 :%s\n",grapherrormessage(errorcode));
   printf(" ⠭   \n");
   getch();
   exit(1);  /* 襭   訡 */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;

/* 横  蠡 */
for(i=EMPTY_FILL; i<USER_FILL; i++)
{
   /* । 蠡 */
   setfillpattern(i,getmaxcolor(1));
   /* ᮢ   */
   fillellipse(midx,midy,xradius,yradius);
   getch();
}
/* ⪠ */
closegraph();
return 0;
}



fillpoly

㭪              訢 㣮쭨.

⠪          #include <graphics.h>
                   void far fillpoly (int numpoints,
                                       int far *polypoints);

, ᮤঠ騩   graphics.h
⨯

ᠭ           fillpoly       㣮쭨  ,騩
                   numpoints 祪, ᯮ ⥪騩    梥
                   (⠪   ,           drawpoly),  ⥬
                   訢 㣮쭨 ⥪騬 梥⮬ ᪨ 
                     ⥪饣 蠡.

                   polypoints 㪠뢠      ᫥⥫쭮   
                   (numpoints x 2) 楫 ᥫ.    ᥫ x 
                   y  न⠬ 設 㣮쭨.

頥       .
祭

७ᨬ      㭪 㭨쭠   Borland  C++.    ࠡ⠥
                   ⮫쪮    IBM PC  ᮢ⨬  ,
                   ᭠饭 ᯫ묨 ࠬ,  ন騬
                   ᪨ ०. 㭪  ᮢ⨬  Windows.

 ⠪     drawpoly, floodfill, graphresult, setfillstyle.

ਬ:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/*  ⮮। */
int graphdriver = DETECT, gmode, errorcode;
int i,maxx,maxy;
/*  㣮쭨 */
int poly[10];

/* 樠 䨪   ६ */
initgraph(&graphdriver,&gmode,"");

/* 祭 १ 樠樨 */
errorcode = graphresult();
if(errorcode != grOk)  /* ᫨ 訡 */
{
   printf("訡 :%s\n",grapherrormessage(errorcode));
   printf(" ⠭   \n");
   getch();
   exit(1);  /* 襭   訡 */
}
maxx = getmaxx();
maxy = getmaxy();

poly[0] = 20;        /* ࢠ 窠 */
poly[1] = maxy/2;

poly[2] = maxx-20;   /* 2 */
poly[3] = 20;

poly[4] = maxx-50;   /* 3 */
poly[5] = maxy-20;

poly[6] = maxx/2;    /* 4 */
poly[7] = maxy/2;

poly[8] = poly[0];   /*   室 . */
poly[9] = poly[1];

/* 横  蠡 */
for(i=EMPTY_FILL; i<USER_FILL; i++)
{
   /* । 蠡 */
   setfillpattern(i,getmaxcolor(1));
   /*   㣮쭨 */
   fillpoly(5,poly);
   getch();
}

/* ⪠ */
getch();
closegraph();
return 0;
}


findfirst

㭪            ᬠਢ ⠫ ᪠.

⠪          #include<dir.h>
                   #include<dos.h>
                   int findfirst(char * pathname, struct ffblk
                                              * ffblk, int attrib);

, ᮤন騩   dir.h
⨯

ᠭ           㭪 findfirst ந   ⠫ ᪠
                   ।⢮ ⥬ 맮 DOS 0x4E.

                   ࠬ pathname   ।⠢  ᮡ  ᨬ
                   ப,  ᮤঠ   易⥫   ᯥ䨪
                   ᪮ ன⢠,  ᪠   ᪮
                   䠩.  䠩  ᮤঠ 蠡 (⠪ 
                   ?      *).  ᫨  ᮮ⢥騩  䠩  ,
                    ffblk  ଠ樥   䠩  
                   ⠫,  ᮤঠ饬.

                   C ffblk । ᫥騬 ࠧ:

                   struct ffblk {
                       char ff_reserved[21];  /* १ࢨ஢ DOS */
                       char ff_attrib;        /* ਡ */
                       int  ff_ftime;         /* ६ */
                       int  ff_fdate;         /*   */
                       long ff_fsize;         /* ࠧ */
                       char ff_fname[13];     /*  䠩 */
                   };

                   ࠬ attrib -  ᯮ㥬    MS-DOS  
                   ਡ  䠩,    㯮ॡ  롮
                   室  ᪠ 䠩. ࠬ attrib 
                       ᫥ ।  䠩 dos.h
                   ⠭:

                   FA_RDONLY - ਡ "⮫쪮 ⥭".
                   FA_HIDDEN -  䠩.
                   FA_SYSTEM - ⥬ 䠩.
                   FA_LABEL  - ⪠ ⮬.
                   FA_DIREC  - ⠫.
                   FA_ARCH   - 娢.

                    ஡  ଠ      ਡ 
                         㬥   "ࠢ筮   㪮⢮
                   ணࠬ  DOS".

                   ⬥⨬,   ff_ftime   ff_fdate ᮤঠ ⮢
                     ।   ६.   
                   ন   DOS.      16-⮢  
                     3 :

                   ff_ftime:
                    0-4      㭤,   2. (.. 10
                                 ᮮ⢥ 20 ᥪ㭤).
                    5-10     
                    11-15    

                   ff_fdate:
                    0-4      
                    5-8      
                    9-15       1980 (.. 9 ᮮ⢥ 1989)

                    ftime   io.h, ᯮ 
                   ६      ᮮ⢥騥  ⮬.   
                   㭪樨 getftime  setftime.

頥        ᯥ譮 襭,    ᯥ譮
祭           ᪥ 䠩, ᮮ⢥饣 ࠬ pathname,
                   㭪 findfirst   頥   祭  0.  ᫨
                   室 䠩   ,   
                   䠩 饭 訡,  㭪  祭
                   -1  쭠 ६ errno 砥    
                   ᫥ 祭:

                   ENOENT -  㯠   䠩  .
                   
                    ६   doserrno   ᢠ      
                   ᫥ 祭:
                   
                   ENOENT -  㯠   䠩  .
                   ENMFILE -   䠩.

७ᨬ      㭪 㭨쭠  DOS.

 ⠪     findnext.

ਬ:

#include <stdio.h>
#include <dir.h>

int main(void)
{
   struct ffblk ffblk;
   int done;
   printf("⨭ ⠫ *.*\n");
   done = findfirst(**.**,&ffblk,0);
   while (!done)  {
     printf(" %s\n", ffblk.ff_name);
     done = findnext(&ffblk);
   }
   return 0;
}

:

⨭ ⠫ *.*
  FINDFRST.C
  FINDFRST.OBJ
  FINDFRST.MAP
  FINDFRST.EXE


findnext

㭪            த ᬮ,  㭪樥 findfirst.

⠪          #include <dir.h>
                   int fidtnext(struct ffblk * ffblk);

, ᮤঠ騩   dir.h
⨯

ᠭ           㭪 findnext     ᯮ        롮ન
                   ᫥⥫쭮     䠩,      ᮮ⢥
                   ࠬ pathname,  㭪樥 findfirst.
                   ffblk -    ᠬ ,   
                    맮 㭪樨 findfirst.    ᮤন
                    室 ଠ  த  ᪠.
                          맮   㭪樨   findnext   㤥
                      䠩   ,  䠩,
                   ᮮ⢥騥 ࠬ, pathname  .

頥        ᯥ譮 襭,    ᯥ譮
祭           ᪥ 䠩, ᮮ⢥饣 ࠬ pathname,
                   㭪 findnext  頥   祭   0.   ᫨
                   室 䠩   ,   
                   䠩 饭 訡,  㭪 頥 祭
                   -1    쭠 ६ errno 砥  
                   ᫥ 祭:
                   
                   ENOENT -  㯠   䠩  .
                   
                    ६   doserrno   ᢠ      
                   ᫥ 祭:
                   
                   ENOENT -  㯠   䠩  .
                   ENMFILE -   䠩.
                   
७ᨬ      㭪 㭨쭠  DOS.

 ⠪     findfirst.

ਬ:

#include <stdio.h>
#include <dir.h>

int main(void)
{
   struct ffblk ffblk;
   int done;
   printf("⨭ ⠫ *.*\n");
   done = findfirst(**.**,&ffblk,0);
   while (!done)  {
     printf(" %s\n", ffblk.ff_name);
     done = findnext(&ffblk);
     }
   return 0;
}

:

⨭ ⠫ *.*
  FINDFRST.C
  FINDFRST.OBJ
  FINDFRST.MAP
  FINDFRST.EXE


floodfill

㭪             ࠭祭 .

⠪          #include <graphics.h>
                   void far floodfill(int x, int y
                                       int border);

, ᮤঠ騩   graphics.h
⨯

ᠭ           floodfill     ࠭祭       
                   ன⢠    ⮢  ⮡ࠦ.  (x,y)   -
                   ந쭠  窠    訢 .
                   ,   ࠭    ன    襭    梥⮬
                   border,   ⥪騬   梥⮬   ᪨  
                   蠡.  ᫨ 㪠  窠  室  
                   ࠭祭  ,  訢  ,  
                   ᫨  ᭠㦨,    訢         
                   । .

                   ᯮ, ᫨    ,  fillpoly  
                   floodfill.          ᯥ   
                   ᮢ⨬  騬 ﬨ.

                   砭. floodfill     ࠡ⠥      ࠩ஬
                   IBM-8514.

頥       ᫨     
祭           訡,  graphresult 頥 祭 -7.

७ᨬ      㭪 㭨쭠    Borland  C++.   ࠡ⠥
                   ⮫쪮   IBM PC  ᮢ⨬   ,
                   ᭠饭 ᯫ묨 ࠬ,  ন騬
                   ᪨ ०. 㭪  ᮢ⨬  Windows.

 ⠪     drawpoly, fillpoly, graphresult, setcolor,
                   setfillstyle.

ਬ:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/*  ⮮। */
int graphdriver = DETECT, gmode, errorcode;
int maxx,maxy;

/* 樠 䨪   ६ */
initgraph(&graphdriver,&gmode,"");

/* 祭 १ 樠樨 */
errorcode = graphresult();
if(errorcode != grOk)  /* ᫨ 訡 */
{
   printf("訡 :%s\n",grapherrormessage(errorcode));
   printf(" ⠭   \n");
   getch();
   exit(1);  /* 襭   訡 */
}
maxx = getmaxx();
maxy = getmaxy();
/* 롮 梥 ᮢ */
setcolor(getmaxcolor());
/* 롮 梥  */
selectfillstyle(SOLID_FILL,getmaxcolor());
/* ᮢ ࠭  ࠭ */
rectangle(0,0,maxx,maxy);
/* ᮢ ᪮쪮 㦭⥩ */
circle(maxx/3,maxy/2,50);
circle(maxx/2,20,100);
circle(maxx-20,maxy-50,75);
circle(20,maxy-20,25);
/*    */
getch();
/*  ࠭祭  */
floodfill(2,2,getmaxcolor());
/* ⪠ */
getch();
closegraph();
return 0;
}


floor

㭪            㣫   ஭.

⠪          #include<math.h>
                   double floor(double x);

, ᮤঠ騩   math.h
⨯

ᠭ           㭪 floor 室 襥 楫 ᫮ 
                   ॢ饥 祭 x.

頥       㭪 頥  楫 ᫮.
祭           ( double).

७ᨬ      㭪 ন ⥬ UNIX  ⠭⮬
                   ANSI C.

 ⠪     ceil, fmod.

ਬ:

#include<math.h>
#include<stdio.h>
int main(void)
{
   double number = 123.54;
   double down,up;
   down = floor(number);
   up = ceil(number);
   printf("室 ᫮:%5.21f\n",number);
   printf("㣫  :%5.21f\n",down);
   printf("㣫  :%5.21f\n",up);
   return 0;
}


flushall

㭪            뢠   ⮪.

⠪          #include<stdio.h>
                   int flushall(void);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 flushall 뢠  , 易 
                   묨   室묨   ⮪,     뢠  
                   ᮮ⢥騥 䠩    ,  ⭮騥  
                     室 ⮪.   樨 ⥭,
                   ᫥騥  㭪樥 flushall     
                     室 䠩  .

                    ⮪  묨.

頥       flushall 頥 ᫮  室  室-
祭           ⮪.

७ᨬ      ন ⥬ UNIX.

 ⠪     fclose, fcloseall, fflush.

ਬ:

#include<stdio.h>
                   
int main(void)
{
   FILE *stream;
   /* ᮧ 䠩 */
   stream = fopen("DUMMY.FIL","w");
   /*    ⮪ */
   printf("襭 %d ⮪\n",flushall());
   /*  䠩 */
   fclose(stream);
   return 0;
}
                   

_fmemccopy

 㭪 memccpy.
                   

_fmemchr

 㭪 memchr.
                        

_fmemcmp

 㭪 memcmp.
                       

_fmemcopy

 㭪 memcpy.
                     

_fmemicmp

 㭪 memicmp.
                        

_fmemset

 㭪 memset.
                       
                   

fmod

㭪             x   y,   ⮪  
                   楫 x/y.

⠪          #include<math.h>
                   double fmod(double x, double y);

, ᮤঠ騩   math.h
⨯

ᠭ           㭪 fmod    x      y  ( 
                   ⮪ f,  㤮⢮騩  ࠢ  x=iy+f  
                   楫 i  0<=f<y).

頥       㭪 fmod 頥 ⮪ f,  x=iy+f
祭           ( ᠭ ).  y=0, fmod ⠪ 頥
                   0.

७ᨬ      ন ⠭⮬ ANSI C.

 ⠪     ceil, floor, modf.

ਬ:

#include<math.h>
#include<stdio.h>

int main(void)
{
   double x=5.0,y=2.0;
   double result;
   result = fmod(x,y);
   printf("⮪   %1f  %1f ࠢ %1f",x,y,result);
   return 0;
}

:

⮪   5.0  2.0 ࠢ 1.0


fnmerge

㭪               䠩  ⤥ ⥩.

⠪          #include <dir.h>
                   void fnmerge(char * path, const char * drive,
                   const char * dir, const char * name,
                   const char * ext);

, ᮤঠ騩   dir.h
⨯

ᠭ           㭪 fnmerge   ᮧ      䠩       
                   ⮢.     䠩,     
                    㯠, ந ᫥騬 ࠧ:

                   X:\DIR\SUBDIR\NAME.EXT   , 

                   X - ᯥ䨪 ன⢠;

                   \DIR\SUBDIR\ - ⠫;

                   NAME - ;

                   .EXT - ७.

                   fnmerge ।,             
                   ஥      㯠   筮
                   .    ᨬ쭠         㯠
                   ।  ⠭⮩  MAXPATH,  ।  
                   dir.h.

                   㭪樨 fnmerge  fnsplit .  ᫨  
                    㭪樨 fnsplit ࠧ    
                   㯠 path,  ⥬ ᮫ 祭 
                     㭪樨 fnmerge,      ᭮  
                    㯠 path.

頥       .
祭

७ᨬ      㭪 ࠡ⠥ ⮫쪮  ⥬ DOS.

 ⠪     fnsplit.

ਬ:

#include<string.h>
#include<stdio.h>
#include <dir.h>

int main(void)
{
    char drive[MAXDRIVE];
    char dir[MAXDIR];
    char file[MAXFILE];
    char ext[MAXEXT];
    char s[MAXPATH];
    getcwd(s,MAXPATH);  /*  ⥪騩 ࠡ稩 ⠫ */
    strcat(s,"\\");     /*  ᨬ \ */
    fnsplit(s,drive,dir,file,ext); /* ࠧ  */
    strcpy(file,"DATA");
    strcpy(ext,".TXT");
    fnmerge(s,drive,dir,file,ext);
    puts(s);
    return 0;
}


fnsplit

㭪               䠩  .

⠪          #include <dir.h>
                   int fnsplit(char * path, char * drive,
                   char * dir, char * name, char * ext);

, ᮤঠ騩   dir.h
⨯

ᠭ           㭪 fnsplit   ⢥ 室 㬥
                       䠩 (   㯠 path) 
                   ଥ :

                   X:\DIR\SUBDIR\NAME.EXT

                          4  ,      
                   ᨬ ப,  묨 㪠⥫ﬨ  
                   :   drive,   dir,  name,  ext.  (  
                   ⮢      祭  NULL,   
                   砥,      뤥,   
                   ࠭).

                   ᨬ ࠧ      ᨬ  ப
                     ⠭⠬  MAXDRIVE,  MAXDIR,  MAXPATH,
                   MAXNAME,  MAXEXT  (।塞묨    䠩  dir.h),
                   祬      砥    ᥡ   
                   樨 㫥 .


⠭          ᨬ쭠            ப
                      

MAXPATH                (80)             path;
MAXDRIVE               (3)              drive;  稥 (:);
MAXDIR                 (66)             dir;  騩 
                                        墮⮢  (\);
MAXFILE                (9)              name;
MAXEXT                 (5)              ext;   (.)


                   㭪 fnsplit  ࠧ㬥,      ࠭
                         筮      (  ᫨
                     祭, ⫨筮  NULL).

                    饯       䠩   (
                   㯠)      㭪  fnsplit  ਭ
                   ᨬ 㭪樨 ᫥騬 ࠧ:

                   -      drive     ࠭      稥,
                     ᮥ  ᯥ䨪樨 ᪮ (C:, A: 
                     .).

                   -  dir ࠭ 騥  墮⮢ 
                     \ (\tc\include\, \source\,  .).

                   -  name 砥  䠩.

                   -  ext ࠭ , ।
                     ७  䠩 (.c, .exe,  ..).

                   㭪樨 fnmerge  fnsplit .  ᫨  
                     㭪樨 fnsplit ࠧ   
                   㯠 path,  ⥬ ᮫ 祭 
                       㭪樨  fnmerge,    ᭮ 
                    㯠 path.

頥       㭪 fnsplit 頥 楫 ᫮ (⠢-
祭             5- 䫠, ᠭ  䠩 dir.h), -
                   ஥ 뢠,       
                   䠩   path;   ᫥ 䫠
                    ,   :

                   EXTENSION - ७  䠩;
                   FILENAME  -  䠩;
                   DIRECTORY - ⠫ (  ⠫);
                   DRIVE     - ᯥ䨪 ᪮ (ᬮ
                               䠩 dir.h);
                   WILDCARD  - 蠡 (* ?).

७ᨬ      㭪 ࠡ⠥ ⮫쪮  ⥬ DOS.

 ⠪     fnmerge.

ਬ:

#include<string.h>
#include<stdio.h>
#include <dir.h>

int main(void)
{
    char drive[MAXDRIVE];
    char dir[MAXDIR];
    char file[MAXFILE];
    char ext[MAXEXT];
    char *s;
    int flag;
      s=getenv("COMSPEC");
      flag = fnsplit(s,drive,dir,name,ext);
      printf("  :");
            if (flag & DRIVE)
              printf("\t᪮: %s\n",drive);
            if (flag & DIRECTORY)
              printf("\t४: %s\n",dir);
            if (flag & FILENAME)
              printf("\t: %s\n",name);
            if (flag & EXTENSION)
              printf("\t७: %s\n",ext);
            return 0;
}


fopen

㭪            뢠 ⮪.

⠪          #include <stdio.h>
                   FILE * fopen(char * filename, char * type);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 fopen     뢠    䠩,    
                   ࠬ஬   filename        뢠        
                   ᮮ⢥騬  ⮪  stream.  㭪  fopen 
                   ⢥ १ 頥   㪠⥫,
                      㤥  ஢  ⮪  stream  
                   ᫥ .

                   ப mode,  ᯮ㥬    㭪樨  fopen 
                   ਭ ᫥騥 祭:

                   r - ⨥ 䠩 ⮫쪮  ⥭;

                   w - ᮧ 䠩  ;

                    - ᮥ; ⨥    
                       䠩  ᮧ  , ᫨ 䠩 
                       ;

                   r+ - ⨥ 饣 䠩  
                        (⥭  );

                   w+ - ᮧ  䠩  ;

                   a+ - ⨥  ᮥ; ⨥ (
                        ᮧ, ᫨ 䠩  )  -
                           䠩.

                   ᫨    䠩   뢠    ᮧ  
                   ⥪⮢ ०,    ਯ ᨬ  t  
                   祭   ࠬ   type   (rt,  w+t,    ..);
                   筮,   ᯥ䨪樨 ୮  ०  
                      祭 ࠬ type  ᨬ b
                   (wb,a+b,  ..).
                   
                   ᫨  ࠬ type  ᨬ t   b,
                   ०   㤥  ।  쭮  ६
                   _fmode.  ᫨  ६  _fmode     祭
                   O_BINARY,   䠩     뢠    ୮
                   ०,  ,  ᫨ _fmode  祭 O_TEXT,
                   䠩   뢠     ⥪⮢  ०.  
                   ⠭ O_... ।  䠩 fcntl.h.

                    ⨨  䠩    ०  (UPDATE),
                     १騬  ⮪  stream      
                   믮  樨 ,  ⠪  뢮.  
                    뢮   ᫥  ।⢥  
                      ⥫⢠ 㭪権 fseek  rewind,
                    ⠪ ,   ਬ 㭪権 fseek, rewind
                       ।⢥ ᫥  뢮 
                   ,  砥  䠩 (EOF).

頥        ᯥ譮 襭 fopen  頥
祭           㪠⥫   ⮪ stream.  砥
                   訡 㭪 頥  (NULL).

७ᨬ      fopen নe  ⥬ UNIX  ।-
                     ANSI C. ஬ ⮣,  ᠭ  
                   Kernighan & Ritchie.

 ⠪     creat, dup, fclose, fdopen, ferror, _fmode (-
                   ), fread, freopen, fseek, fwrite, open,
                   rewind, setmode, setmode.


ਬ:

/* ணࠬ ᮧ 㡫 AUTOEXEC.BAT */

#include <stdio.h>

int main(void)
{
   FILE *in, *out;

   if((in = fopen("\\AUTOEXEC.BAT","rt"))==NULL)
   {
     fprintf(stderr, "   䠩 \n");
     return(1);
   }

   if((out = fopen("\\AUTOEXEC.BAK","wt"))==NULL)
   {
     fprintf(stderr, "   室 䠩 \n");
     return(1);
   }

while(!feof(in))
    fputc(fgetc(in), out);

fclose(in);
fclose(out);
return 0;
}


FP_OFF

㭪            FP_OFF -  砥   ᬥ饭   "쭥"   
                   (  ਡ⮬ "far").

⠪          #include <dos.h>
                   unsigned FP_OFF(void far *p);

, ᮤঠ騩   dos.h
⨯

ᠭ           ப FP_OFF  ᯮ  祭 
                   ⠭ ᭮ ᬥ饭 㪠⥫   ਡ⮬
                   "far".

頥       㭪 FP_OFF 頥 楫 ᫮  ,
祭           ।⠢饥 ᮡ 祭 ᭮ ᬥ饭.

७ᨬ      FP_OFF 㭨쭠  DOS.

 ⠪     FP_SEG, MK_FP, movedata, segread.

ਬ:

#include<dos.h>
#include<stdio.h>

int main(void)
{
   char *str = "fpoff.c";
   printf(" 饭 ⮩ ப ࠢ %X\n",FP_OFF(str));
   return 0;
}


_fpreset

㭪            믮  ⥬᪮  権
                    饩 窮.

⠪          #include<float.h>
                   void _fpreset();

, ᮤঠ騩   float.h
⨯

ᠭ           㭪 _fpreset 믮   ⥬᪮
                    権  饩 窮.   㭪
                   筮  ᯮ      㭪ﬨ  signal,
                   system,  㭪ﬨ exec...  spawn...

                   ਬ砭.  ࠡ    樮  ⥬
                   DOS,  ᫨   ணࠬ ᯮ ⥬᪨
                   ᮯ 80x87,  "୨"  (믮塞
                   ।⢮ 㭪権 system,  exec...  spawn...),
                       ﭨ  権     饩
                   窮 "த⥫᪮" .

                   ᫨    ᯮ  ᮯ  80x87,  ਬ
                   ᫥騥 ।஦:

                   -   뢠  㭪樨  exec...,   spawn...   
                     system,    ࠦ    饩  窮 
                     ᫥.

                   -  ⠭ 権  饩  窮  ᫥
                     ᯮ짮   㭪権   system,   exec...   
                     spawn...  뢠 㭪 _fpreset (᫨ ⮫쪮
                         -   蠭   믮   ୨
                     ᮬ   権        饩    窮,
                     ।⢮ ᮯ 8087/80287).

頥       .
祭
                   
७ᨬ      _fpreset 㭨쭠  DOS.
                   
 ⠪     clear87, _control87, exec...,  spawn...,
                   _status87, system.

ਬ:

#include<stdio.h>
#include<float.h>
#include<setjmp.h>
#include<signal.h>
#include<process.h>
#include<conio.h>

jmp_buf reenter;

/* । ணࠬ ࠡ⪨ 訡 権 権 
   饩 窮 */
void float_trap(int sig)
{
   printf("뢠  訡 権  饩 窮.\n");
   printf(" த ࠡ   ...\n");
   getch();
   /*  ᮯ   */
   _fpreset();
   /*   ,  ன  訡 */
   longjmp(reenter,-1);
}
int main(void)
{
   float one = 3.14, two = 0.0;
   /* ⠭ ணࠬ ࠡ⪨ ᪫⥫ 権 権
       饩 窮 */
   if(signal(SIGFPE,float_trap) == SIG_ERR)
   {
      printf("訡  ⠭ ணࠬ ࠡ⪨ 뢠\n");
      exit(3);
   }
   printf(" ⥬᪮ 訡.  ...\n");
   getch();
   if(setjmp(reenter)==0)
     one /* two;
   printf(" ᫥ ࠡ⪨ 뢠.\n");
   return 0;
}


fprintf

㭪            뫠 ଠ஢ 뢮  ⮪.

⠪          #include <stdio.h>
                   int fprintf(FILE * stream, const char *format
                   [,argument,...]);

, ᮤঠ騩   stdio.h
⨯

ᠭ           fprintf 砥    㬥⮢,     
                    ᯥ䨪樨 ଠ,    뢮    
                   ⮪.  ⢮  㬥⮢    ᮢ 
                   ᫮ ᯥ䨪権.

                   ᠭ ᯥ䨪権  ଠ ਢ  ᠭ
                   㭪樨 printf.

頥       fprintf 頥 ᫮ 뢥 .  -
祭            訡 頥 EOF.

७ᨬ      fprintf ᮢ⨬  ⥬ UNIX  ন-
                    ⠭⮬ ANSI C.  ᬥ⨬  Kernichan &
                   Rithie.

 ⠪     cprintf, fscanf, printf, putc, sprintf.

ਬ:

#include<stdio.h>

int main(void)
{
   FILE *stream;
   int i=100;
   char c = 'C';
   float f = 1.234;
   /*  䠩   */
   stream = fopen("DUMMY.FIL","w+");
   /* 뢥  䠩  */
   fprintf(stream,"%d %c %f",i,c,f);
   /*  䠩 */
   fclose(stream);
   return 0;
}


FP_SEG

㭪            砥    ᥣ       ਡ⮬    "far"
                   (쭨).

⠪          #include <dos.h>
                   unsigned FP_SEG(void far *p);

, ᮤঠ騩   dos.h
⨯

ᠭ          ப FP_SEG  ᯮ  祭 
                   ⠭ 祭   ᥣ    ᭮
                   㪠⥫  ਡ⮬ "far".

頥      㭪 FP_SEG 頥 楫 ᫮  ,
祭          ।⠢饥 ᮡ 祭  ᥣ.

 ⠪     FP_OFF, MK_FP, movedata, segread.

ਬ:

#include<dos.h>
#include<stdio.h>

int main(void)
{
   char *str = "fpoff.c";
   printf("  ᥣ ⮩ ப ࠢ %X\n",FP_SEG(str));
   return 0;
}


fputc

㭪            뢮 ᨬ  ⮪.

⠪          #include <stdio.h>
                   int fputc(int c, FILE * stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 fputc 뢮 ᨬ   ⮪ stream.

頥        砥 ᯥ 頥 ᨬ .
祭            砥 訡 頥 EOF.

७ᨬ      ন ⥬ UNIX  ⠭⮬ ANSI C.

 ⠪     fgetc,putc.

ਬ:

#include<stdio.h>
int main(void)
{
   char msg[] = "ࠢ ";
   int i=0;
   while(msg[i])
   {
      fputc(msg[i],stdout);
      i++;
   }
   return 0;
}


fputchar

㭪            뢮 ᨬ  ⮪ stdout.

⠪          #include <stdio.h>
                   int fputchar(int c);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 fputchar 뢮 ᨬ   ⮪ stdout.
                   fputchar(c) ।  fputc(c,stdout).

頥        砥 ᯥ 頥 ᨬ .
祭            砥 訡 頥 EOF.

७ᨬ      C⨬  ⥬ UNIX.

 ⠪     fgetchar,putchar.

ਬ:

#include<stdio.h>
int main(void)
{
   char msg[] = "⮢ ਬ";
   int i=0;
   while(msg[i])
   {
      fputchar(msg[i]);
      i++;
   }
   return 0;
}


fputs

㭪            뢮 ப ᨬ  ⮪.

⠪          #include <stdio.h>
                   int fputs(char * string, FILE * stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 fputs  ப, ࠭祭 㫥
                   ⮬    ⮪  stream.      
                   ப ᨬ 室   ப   뢮
                   㫥 ᨬ.

頥        ᯥ譮 襭 fputs 頥 ᫥
祭           뢥 ᨬ.  ⨢ 砥 頥
                   EOF.

७ᨬ      fputs ন ⥬ UNIX  ⠭⮬
                   ANSI C.   ஬  ⮣  ।    Kernighan  &
                   Ritchie.

C ⠪     fgets, gets, puts.

ਬ:

#include<stdio.h>

int main(void)
{
   /* 뢥 ப  ⮪ */
   fputs("⮢ ਬ",stdout);
   return 0;
}


fread

㭪            뢠   ⮪.

⠪          #include <stdio.h>
                   size_t fread(void *ptr, size_t size, size_t n,
                                                      FILE * stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 fread 뢠 n ⮢ ,  
                     size  ⮢,    ⮪  stream    
                   ᭮ 뫪 ptr.

                   饥 ᫮   ࠢ n x size.

頥        ᯥ譮 襭 㭪 -
祭           頥 ⢮ ⮢  ( ), ॠ쭮
                   ⠭.

                    砥  ⨦   䠩  
                   訡  㭪  fread   頥   short   count
                   ( 0).

७ᨬ       㭪 ন ⥬ UNIX 
                   ⠭⮬ ANSI C.

 ⠪     fopen, fwrite, printf, read.

ਬ:

#include<string.h>
#include<stdio.h>

int main(void)
{
   FILE *stream;
   char msg[] = "⮢ ਬ";
   char buf[20];
   if(stream = fopen("DUMMY.FIL","w+")) == NULL)
   {
      fprintf(stderr,"   䠩\n");
      return 1;
   }
   /* 뢥  䠩  */
   fwrite(msg,strlen(msg)+1,1,stream);
   /* ३  砫 䠩 */
   fseek(stream,SEEK_SET,0);
   /*   */
   fread(buf,strlen(msg)+1,1,stream);
   printf("%s\n",buf);
   fclose(stream);
   return 0;
}


free

㭪            ᢮ , 뤥  .

⠪          #include<alloc.h>
                   void free(void *block);

, ᮤঠ騩   stdlib.h  alloc.h
⨯

ᠭ           free ᢮  , 뤥 㭪ﬨ
                   calloc, malloc  realloc.

頥       .
祭

७ᨬ      free ᮢ⨬  ⥬ UNIX  ন
                   ⠭⮬ ANSI C.

 ⠪     calloc, freemem, malloc, realloc, strdup.

ਬ:

#include<string.h>
#include<stdio.h>
#include<alloc.h>

int main(void)
{
   char *str;
   /* 뤥   ப */
   str = malloc(10);
   /* ᪮஢  ப "Hello" */
   strcpy(str,"Hello");
   /* 뢥 ப */
   printf("ப: %s\n",str);
   /* ᢮  */
   free(str);
   return 0;
}


freemem

㭪            ᢮ ࠭ 뤥  .

⠪          #include<dos.h>
                   int freemem(unsigned seg);

, ᮤঠ騩   dos.h
⨯

ᠭ           freemem ᢮             뤥
                   ।⢮訬  맮  allocmem.  seg  -  
                   ᥣ 뤥 .

頥        ᯥ譮 襭 頥 0,  訡
祭           頥 -1  ⠭  ६
                   erron ࠢ:

                   ENOMEM - 筮 .

 ⠪     allocmem, free.

ਬ:

#include<dos.h>
#include<alloc.h>
#include<stdio.h>

int main(void)
{
   unsigned int size,segp;
   int stat;
   size = 64;  /* 뤥  ࠧ஬ 1024 (6416)  */
   stat = allocmem(size,&segp);
   if(stat == 0)
      printf(" 뤥  ᥣ %X\n",segp);
   else
      printf("ᨬ쭮 㯭 %u ࠣ䮢 \n",stat);
   freemem(segp);
   return 0;
}


freopen

㭪            뢥  ⮪  䠩.

⠪          #include <stdio.h>
                   FILE * freopen(char * filename, char * mode,
                               FILE *stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 freopen 頥 㪠 䠩  
                   ⮪   stream.  㭪  freopen  뢠  䠩,
                   易   stream,  ᨬ    ࠢ
                   䠩.   ᯮ짮   ⮪,
                   易  stdin, stdout  stderr.

                   ப mode,  ᯮ㥬  㭪樨 freopen, 
                   ਭ ᫥騥 祭:

                   r - ⨥ 䠩 ⮫쪮  ⥭;

                   w - ᮧ 䠩  ;

                    - ᮥ;  ⨥        
                       䠩    ᮧ   ,  ᫨ 䠩 
                       ;

                   r+ - ⨥ 饣  䠩    
                        (⥭  );

                   w+ - ᮧ  䠩  ;

                   a+ - ⨥    ᮥ;  ⨥  (
                        ᮧ,  ᫨  䠩      )   
                           䠩.

                   ᫨    䠩   뢠    ᮧ  
                   ⥪⮢ ०,    ਯ ᨬ  t  
                   祭   ࠬ   mode   (rt,  w+t,    ..);
                   筮,   ᯥ䨪樨 ୮  ०  
                      祭 ࠬ mode  ᨬ b
                   (wb,a+b,  ..).
                   
                   ᫨  ࠬ mode  ᨬ t   b,
                   ०   㤥  ।  쭮  ६
                   _fmode.  ᫨  ६  _fmode     祭
                   O_BINARY,   䠩     뢠    ୮
                   ०,  ,  ᫨ _fmode  祭 O_TEXT,
                   䠩   뢠     ⥪⮢  ०.  
                   ⠭ O_... ।  䠩 fcntl.h.

                    ⨨  䠩    ०  (UPDATE),
                     १騬  ⮪  stream      
                   믮  樨 ,  ⠪  뢮.  
                    뢮   ᫥  ।⢥  
                      ⥫⢠ 㭪権 fseek  rewind,
                    ⠪   ਬ 㭪権  fseek,  rewind
                       ।⢥ ᫥  뢮 
                   ,  砥  䠩 (EOF).

頥        ᯥ譮 襭, freopen  頥
祭           㪠⥫   ⮪ stream.  砥
                   訡, 㭪 頥  (NULL).

७ᨬ      freopen নe  ⥬ UNIX
                    ᮢ⨬  ⠭⮬ ANSI C.

 ⠪     fclose, fdopen, fopen, open, setmode.

ਬ:

#include<stdio.h>

int main(void)
{
   /* ७ࠢ ⠭ 뢮  䠩 */
   if(freopen("OUTPUT.FIL","w",stdout) == NULL)
     fprintf(stderr,"訡 ७ࠢ ⮪\n");
   /*  뢮 㤥 ⢫  䠩 */
   printf(" 뢮 㤥 ⢫  䠩\n");
   /*  ⠭ 뢮 */
   close(stdout);
   return 0;
}


frexp

㭪            饯 ᫮  筮   
                   冷.

⠪          #include<math.h>
                   double frexp(double value, int * exponent);

, ᮤঠ騩   math.h
⨯

ᠭ           frexp     m (⨯ double,  襥
                    ࠢ 0.5   1.0)  楫 n,  ⠪, 
                   x  ࠢ  m  x  2^n.  frexp  ࠭  n    楫
                   ६,   㪠뢠 exponent.

頥       frexp 頥  m.
祭

                   ࠡ 訡  ﭨ     frexp   
                   ஢   㭪樨 matherr.

७ᨬ      frexp ᮢ⨬  UNIX  ন ⠭⮬
                   ANSI C.

 ⠪     exp, ldexp.

ਬ:

#include<math.h>
#include<stdio.h>

int main(void)
{
   double mantissa,number;
   int exponent;
   number = 8.0;
   mantissa = frexp(number,&exponent);
   printf("᫮ %1f ࠢ %1f 㬭  2  ⥯ %d\n",
         number,mantissa,exponent);
   return 0;
}


fscanf

㭪            믮 ଠ஢   ⮪.

⠪          #include <stdio.h>
                   int fscanf(FILE * stream, char * format[,
                   adress,...]);

, ᮤঠ騩   stdio.h
⨯

ᠭ           fscanf ᪠  ᨬ쭮   ,
                   뢠   ⮪.  ⥬    ⮪
                   ଠ      ᮮ⢥⢨    ᯥ䨪樥
                   ଠ,  । fscanf   㪠⥫
                     ப  format.  祭   १ ⮣
                    fscanf    㬥,  ।
                   㭪樨  fscanf ᫥ ࠬ format.  ⢮
                   㬥⮢      ᮢ        ⢮
                   ᯥ䨪権 ଠ.

                   ᠭ ᯥ䨪権 ଠ ਢ   ᠭ
                   㭪樨 scanf.

                   fscanf 蠥  ᪠஢  ⤥쭮  
                    ஡,  饣  ࠧ⥫,  
                      ,   ண 㪠 ਭ.  
                   砨 㦤  ᠭ 㭪樨 scanf.

頥       㭪 fscanf 頥 ⢮ ᯥ譮 -
祭           ⠭, ८ࠧ   室
                   ; 頥 祭    砥    ᥡ
                   ⠭ ,   뫨 ࠭.

                   ᫨ fscanf   ⥭   䠩, 
                   頥 EOF.  ᫨  뫮 ᠭ   
                   , 頥 祭 0.

७ᨬ      㭪 fscanf ন  ⥬ UNIX
                    ।  ⠭ Kernighan &  Ritchie.  
                   ন ⠭⮬ ANSI C.

 ⠪     atof, cscanf, fprintf, printf, scanf, sscanf,
                   vfscanf, vscanf, vsscanf.

ਬ:

#include<stdlib.h>
#include<stdio.h>

int main(void)
{
   int i;
   printf(" 楫 ᫮:");
   /*   ⠭⭮ ⮪ stdout 楫 ᫮ */
   if(fscanf(stdin,"%d",&i))
     printf(" ࠢ:%d\n",i);
   else
    {
     fprintf(stderr,"訡 ⥭ 楫\n");
     exit(1);
    }
   return 0;
}


fseek

㭪            ⠭ 㪠⥫ 䠩  ⮪.

⠪          #include <stdio.h>
                   int fseek(FILE * stream, long offset,
                                                    int fromwhere);

, ᮤঠ騩   stdio.h
⨯

ᠭ           㭪 fseek   ⠭     㪠⥫
                   䠩,  ᮮ⢥騩  ⮪  stream,     
                   ,    ᯮ    ᬥ饭 offset
                   ⭮⥫쭮          䠩,    ।塞
                   ࠬ஬ fromwhere.

                   ࠬ fromwhere             
                   祭  0,  1   2,   ।⠢ ६
                   ᨬ᪨ ⠭⠬ (।묨    䠩
                   stdio.h), ᫥騬 ࠧ:

                   
                   ࠬ             饭  䠩
                   fromwhere
                   
                   SEEK_SET (0)          砫 䠩;
                   SEEK_CUR (1)           ⥪饣 㪠⥫
                                         䠩;
                   SEEK_END (2)           䠩 (EOF);
                   

                   㭪 fseek 뢠  ᨬ, ᠭ 
                    㭪樨 ungetc.

                   㭪 fseek     ᯮ          ﬨ
                   /뢮    ⮪.    ࠡ  ਯ஬
                   䠩  㭪樥 lseek.

                   ᫥ ⮩ 樨  ந  , ⠪
                    뢮  ⮪.

頥       㭪 fseek 頥 祭 0, ᫨
祭           㪠⥫ 䠩 ᯥ譮 ६饭,  㫥
                   祭  砥 㤠筮 襭.

                   ਬ砭. 㭪  fseek      㫥
                   祭   砥,  ᫨ ⮣    뫮.  
                   ந室   १ ⮣,   DOS,   
                   ६頥 㪠⥫,   ஢   ⠭.
                   fseek  頥  訡 ⮫쪮  砥,
                   ᫨ ன⢮  䠩  .

७ᨬ       㭪 ন  ⥬ UNIX
                    ⠭⮬ ANSI C.

 ⠪     fgetpos, fopen, fsetpos, ftell, lseek, rewind,
                   setbuf, tell.

ਬ:

#include <stdio.h>
int main(void)
{
   FILE *stream;
   stream = fopen("MYFILE.TXT", "r");
   print("filesize of MYFILE.TXT is %ld bytes\n",
          filesize(stream));
}
long filesize(FILE *stream);
{
   long curpos,length;
   /* ࠭ ⥪饥  㪠⥫ */
   curpos = ftell(stream);
   /* ३   䠩 */
   fseek(stream, 0L, SEEK_END);
   /*  ⥪饥  㪠⥫ */
   length = ftell(stream);
   /* ⠭ ஥  */
   fseek(stream, curpos, SEEK_SET);
   return(length);
}


fsetpos

㭪            樮 㪠⥫ ⥪饩 樨  䠩,
                   易  ⮪ stream.

⠪          #include<stdio.h>
                   int fsetpos(FILE *stream, const fpos_t *pos);

 ᮤঠ騩    stdio.h
⨯

ᠭ           fsetpos ⠭   㪠⥫  ⥪饩  樨
                   䠩, 易  ⮪ stream   ,
                       ।    祭,    砥
                   ।騬  맮  㭪樨  fgetpos.  fsetpos
                   ⠪   뢠   ਧ    䠩,    
                   뢠 ﭨ  ᨬ,  頥    ⮪
                   㭪樥   ungetc.   ᫥   맮  fsetpos  
                   ந  樨 , ⠪  뢮.

頥        ᯥ譮 襭 fsetpos 頥 0. 
祭            訡  頥 㫥
                   祭  ⠭ errno  ࠢ 0.

७ᨬ      fsetpos ন ⠭⮬ ANSI C.

 ⠪     fgetpos, fseek, ftell.

ਬ:

#include<stdlib.h>
#include<stdio.h>

void showpos(FILE *stream);

int main(void)
{
   FILE *stream;
   fpos_t filepos;
   /*  䠩   */
   stream = fopen("DUMMY.FIL","w+");
   /* ࠭ ⥪  㪠⥫ */
   fgetpos(stream,&filepos);
   /*   䠩  */
   fprintf("stream," ");
   /* 뢥 ⥪  */
   showpos(stream);
   /* ⠭    뢥  */
  if(fsetpos(stream,&filepos) == 0)
     showpos(stream);
   else
   {
     fpritf(stderr,"訡 㪠⥫ 䠩\n");
     exit(1);
   }
   /*  䠩 */
   fclose(stream);
   return 0;
}
void showpos(FILE *stream)
{
   fpos_t pos;
   /* 뢥 ⥪饥  㪠⥫ */
   fgetpos(stream,&pos);
   printf(" 㪠⥫: %ld\n",pos);
}


fstat

㭪            砥 ଠ  ⮬ 䠩.

⠪          #include <sys\stat.h>
                   int fstat(char * handle, struct stat * buff)

, ᮤঠ騩   sys\stat.h
⨯

ᠭ           㭪 fstat  뢠  ଠ    ⮬
                   䠩  (  ४ਨ),  易  ਯ஬
                   handle    stat.  A㬥  buff  
                     stat  (।  䠩 sys\stat.h).
                    ᮤন ᫥騥 :

                   st_mode - ⮢ ᪠,  ଠ  ०
                              䠩;

                   st_dev - 䨪 ᪮,    ஬  
                             䠩,    handle,  ᫨ 䠩
                            室  ன⢥;

                   st_rdev - ⠪ ,   st_dev;

                   st_nlink - ᢠ 楫 ⠭ 1;

                   st_size - ࠧ ⮣ 䠩  ;

                   st_atime - 襥 ६  䠩,  ६
                              ண   ஢;

                   st_mtime - ⠪ ,   st_atime;

                   st_ctime - ⠪ ,   st_atime.

                    stat  ᮤন      ,  祬
                   ᫥ ,   ᮤঠ ,  
                   ࠢ DOS   祭.

                   ⮢ ᪠,  ଠ  ० ⮣
                   䠩, ᮤন ᫥騥 :

                     ᫥ ⮢   ⠭:

                   S_IFCHR -   ⠭,   ᫨   ࠬ    handle
                               㪠뢠  ன⢮ (fstat);

                   S_IFREG -    ⠭,    ᫨        䠩
                                । ࠬ஬ handle

                          ᫥           
                   ⠭:

                   S_IWRITE -   ⠭,  ᫨  짮⥫  
                                ࠧ襭  ;

                   S_IREAD -  ⠭,  ᫨   짮⥫   
                              ࠧ襭  ⥭.

                   ⮢ ᪠  ⠪   ⥭/,  
                   ⠭  ᮮ⢥⢨  ० 㯠  
                   䠩.

頥       ᫨ ଠ  ⮬ 䠩 뫠 ᯥ譮 -
祭           祭, 㭪  祭 0.  砥
                   訡 (    ଠ),  㭪
                   頥 -1  ᢠ ६ errno:

                   EBADF -   䠩.

 ⠪     access, chmod, stat.

ਬ:

#include<sys\stat.h>
#include<stdio.h>
#include<time.h>

int main(void)
{
   struct stat statbuf;
   FILE *stream;
   /*  䠩   */
   if((stream = fopen("DUMMY.FIL","w+")) == NULL)
   {
      fprintf(stderr,"   䠩.\n");
      return 1;
   }
   fprintf(stream," ");
   fflush(stream);
   /*  ଠ  䠩 */
   fstat(fileno(stream),&statbuf);
   /* 뢥 祭 ଠ */
   if(statbuf.st_mode & S_IFCHR)
     printf(" ன⢮\n");
   if(statbuf.st_mode & S_IFREG)
     printf(" 䠩\n");
   if(statbuf.st_mode & S_IREAD)
     printf("襭  ⥭\n");
   if(statbuf.st_mode & S_IWRITE)
     printf("襭  ");
   printf("⪠ ᪠:%c\n",'A'+statbuf.st_dev);
   printf("  : %ld\n",statbuf.st_size);
   printf("६ ᫥ : %s\n",
           ctime(&statbuf.st_ctime));
   return 0;
}
                           

_fstrcat

 㭪 strcat.
                   

_fstrchr

 㭪 strchr.
                       

_fstrcspn

 㭪 strcspn.
                        

_fstrdup

 㭪 strdup.
                       

_fstricmp

 㭪 stricmp.
                        

_fstrlen

 㭪 strlen.
                       

_fstrlwr

 㭪 strlwr.
                       

_fstrncat

 㭪 strncat.
                     

_fstrncmp

 㭪 strncmp.
                        

_fstrncmp

 㭪 strncmp.
                        

_fstrnicmp

 㭪 strnicmp.
                         

_fstrnset

 㭪 strnset.
                        

_fstrpbrk

 㭪 strpbrk.
                        

_fstrrchr

 㭪 strrchr.
                        

_fstrrev

 㭪 strrev.
                       

_fstrset

 㭪 strset.
                       

_fstrspn

 㭪 strspn.
                       

_fstrstr

 㭪 strstr.
                       

_fstrtok

 㭪 strtok.
                       

_fstrupr

 㭪 strupr.
                   

ftell

㭪            頥  㪠⥫ ⥪饩 樨
                   䠩.

⠪          #include <stdio.h>
                   long int ftell(FILE *stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           ftell 頥       㪠⥫   ⥪饩
                   樨  䠩,  易      ⮪   stream.
                   祭   뤠        ᬥ饭    
                   ⭮⥫쭮 砫 䠩.

                   祭, 頥  ftell,     쭥襬
                   ᯮ짮  맮 㭪樨 fseek.

頥       ftell 頥  㪠⥫ ⥪饩 -
祭           樨  ᯥ譮 襭.  訡 頥
                   -1L,  ᢠ ६  errno  ⥫쭮
                   祭.

७ᨬ      ftell 㯭  ⥬ UNIX  ন
                   ⠭⮬ ANSI C.

 ⠪     fgetpos, fseek, fsetpos, lseek, rewind, tell.

ਬ:

#include<stdio.h>

int main(void)
{
   FILE *stream;
   stream = fopen("DUMMY.FIL","w+");
   fprintf(stream," ");
   printf("⥫ 䠩: %ld\n",ftell(stream));
   return 0;
}


ftime

㭪            頥 ⥪饥 ६   ⨯ timeb.

⠪          #include<sys\timeb.h>
                   void ftime(struct timeb *buf)

, ᮤঠ騩   sys\timeb.h
⨯

ᠭ           ftime ।  ⥪饥  ६     
                    ⨯ timeb,   㪠뢠 ࠬ
                   buf.  timeb । ᫥騬 ࠧ:

                   struct timed {
                   long      time;
                   short     millitm;
                   short     timezone;
                   short     dstflag;
                   };

                   time -       ᮤন  ६    ᥪ㭤  
                   00:00:00  1  ﭢ  1970        ਭ᪮
                   ਤ.

                   millitm - ᮤন  ᥪ㭤  ᥪ㭤.

                   timezone -   ᮤন   ࠧ       
                   ६  ਭ   ६.   ६
                     ࠢ    ਭ᪮
                   ਤ.   ftime   ।      ६    
                   ᮤন 쭮 ६ timezone, 
                   ⠭ 㭪樥 tzset.

                   dstflag - ࠢ 0,  ᫨ ⭥ ६  ,
                     0,   ⨢ 砥.    ।
                    쭮 ६ daylight  (⠭
                   㭪樥 tzset).

                   ਬ砭. ..  㭪  ftime  뢠  㭪
                   tzset,    室  .

頥       .
祭

७ᨬ       㭪 㯭  ⥬ UNIX System V.

 ⠪     asctime, ctime, gmtime, localtime, stime, time,
                   tzset.

ਬ:

#include<stdio.h>
#include<stdio.h>
#include<time.h>
#include<sys\timeb.h>

char *tzstr = "TZ=PST8PDT";

int main(void)
{
   struct timeb t;
   putenv(tzstr);
   tzset();

   ftime(&t);
   printf("%ld ᥪ㭤  1-1-70  GMT\n",t.time);
   printf(" %d ᥪ㭤",t.millitm);
   printf("%d   GMT",t.timezone);
   printf("⭥ ६ %s ",
                 t.dstflag ? "":"");
   return 0;
}


fwrite

㭪            뢠   ⮪.

⠪          #include <stdio.h>
                   size_t fwrite(void * ptr, size_t size,
                                      size_t n, FILE * stream);

, ᮤঠ騩   stdio.h
⨯

ᠭ           fwrite    n   ⮢   ,   
                   稭 size    室 ⮪. 
                   뢠  ptr.

                   饥 ᫮ 뢥  ࠢ n*size.

                   ptr     㪠⥫  
                   ꥪ.

頥        ᯥ譮 襭 fwrite 頥 ᫮
祭           뢥 ⮢ ( ).  訡 
                   頥 襥 ᫮.

७ᨬ      fwrite 㯭  ⥬ UNIX  ন
                   ⠭⮬ ANSI C.

 ⠪     fopen, fread.

ਬ:

#include<stdio.h>

struct mystruct
{
   int i;
   char ch;
}
int main(void)
{
   FILE *stream;
   struct mystruct s;
   /*  䠩 TEST.$$$ */
   if((stream = fopen("TEST.$$$","wb"))==NULL)
   {
      fprintf(stderr,"   䠩\n");
      return 0;
   }
   s.i = 0;
   s.ch = 'A';
   /* 뢮  䠩 */
   fwrite(&s,sizeof(s),1,stream);
   fclose(stream);
   return 0;
}
