Advertisement
sujonshekh

Read nd write inputs

Jul 15th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. main() {
  4. //   FILE *fp;
  5. //
  6. //   fp = fopen("test.txt", "w+");
  7. //   fprintf(fp, "This is testing for fprintf...\n");
  8. //   fputs("This is testing for fputs...\n", fp);
  9. //   fclose(fp);
  10.  
  11.  
  12.    FILE *fp;
  13.    char buff[255];
  14.  
  15.    fp = fopen("test.txt", "r");
  16.    fscanf(fp, "%s", buff);
  17.    printf("1 : %s\n", buff );
  18.  
  19.    fgets(buff, 255, (FILE*)fp);
  20.    printf("2: %s\n", buff );
  21.  
  22.    fgets(buff, 255, (FILE*)fp);
  23.    printf("3: %s\n", buff );
  24.    fclose(fp);
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement