Virajsinh

FileHandling_9_Binary_Write

Dec 4th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. //Write Binary File fread();
  2.  
  3. #include<stdio.h>
  4. #include<conio.h>
  5.  
  6. void main()
  7. {
  8.     FILE *fp;
  9.     size_t count;
  10.     char str[] = "GOOD MORNING";
  11.     clrscr();
  12.    
  13.     fp = fopen("Welcome.txt", "wb");
  14.    
  15.     if(fp==NULL)
  16.     {
  17.         printf("\n The file could not be opened");
  18.         exit(1);
  19.     }
  20.    
  21.     count = fwrite(str, strlen(str), 1, fp);
  22.    
  23.     printf("\n %d bytes were written to the files", count);
  24.    
  25.     fclose(fp);
  26.     getch();
  27. }
Add Comment
Please, Sign In to add comment