Write Text to the Device File Monitor - C File

C examples for File:Standard Device

Description

Write Text to the Device File Monitor

Demo Code

#include <stdio.h>

int main()//from w w w  . ja  va  2 s. c o  m
{
     int m, k;
     FILE *fptr;
     fptr = fopen("C:\\Code\\data.txt", "r");
     if (fptr != NULL){
          puts("file opened successfully.");
          m = fgetc(fptr);
        
          while(m != EOF){
              fputc(m, stdout);
              m = fgetc(fptr);
          }
        
          k = fclose(fptr);
          if(k == -1)
              fprintf(stderr, "Disk-file closing failed\n");
          if(k == 0)
              puts("Disk-file closed successfully.");
     }else
          fprintf(stderr, "Disk-file opening failed\n");
    
     return(0);
}

Result


Related Tutorials