C putw

C putw function is used to write an integer to the file.

Syntax:
int putw( int c, FILE * stream );
Example:
int main (void)
{
   FILE *fileName;
   int i=2, j=3, k=4, n;
   fileName = fopen ("anything.c","w");
   putw(i, fileName);
   putw(j, fileName);
   putw(k, fileName);
   fclose(fileName);
 
   fileName = fopen ("test.c","r");
   while(getw(fileName)! = EOF)
   {
      n= getw(fileName);
      printf("Value is %d \t: ", n);
   }
   fclose(fp);
   return 0;
}

Scroll Back to Top