Horje
fread Code Example
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\n", buffer);
   fclose(fp);
   
   return(0);
}




C

Related
C# special character display Code Example C# special character display Code Example
c bubble sort Code Example c bubble sort Code Example
string in c Code Example string in c Code Example
print 0 1 2 3 4 in c while loop Code Example print 0 1 2 3 4 in c while loop Code Example
bubble sort in C Code Example bubble sort in C Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9