Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

fread

//from tutorialspoint.com
#include <stdio.h>
#include <string.h>

int main () {
   FILE *fp;
   char c[] = "this is tutorialspoint";
   char buffer[100];

   /* Open file for both reading and writing */
   fp = fopen("file.txt", "w+");

   /* Write data to the file */
   fwrite(c, strlen(c) + 1, 1, fp);

   /* Seek to the beginning of the file */
   fseek(fp, 0, SEEK_SET);

   /* Read and display data */
   fread(buffer, strlen(c)+1, 1, fp);
   printf("%s
", buffer);
   fclose(fp);
   
   return(0);
}
 
PREVIOUS NEXT
Tagged: #fread
ADD COMMENT
Topic
Name
5+2 =