title: Attempting to create a FAT file system in C++?
body: <p>I'm attempting to create a FAT file system I understand the basic principle of how its supposed to set up and I'm using a struct like this for each FAT entry</p>
  
  <pre><code>struct FATEntry
  {
      char      name[20];  /* Name of file */
      uint32_t  pos;       /* Position of file on disk (sector, block, something else) */
      uint32_t  size;      /* Size in bytes of file */
      uint32_t  mtime;     /* Time of last modification */
  };
  </code></pre>
  
  <p>I'm essentially creating a 2 MB file to act as my file system. From there I will write and read files into blocks of 512 bytes each. My question how I can write a struct to a file? Does fwrite allow me to do this? For example:</p>
  
  <pre><code>struct FATEntry entry1;
  strcpy(entry1.name, "abc");
  entry1.pos = 3;
  entry1.size = 10;
  entry1.mtime = 100;
  cout &lt;&lt; entry1.name;
  
  file = fopen("filesys", "w");
  fwrite(&amp;entry1,sizeof(entry1),1,file);
  fclose(file);
  </code></pre>
  
  <p>Will that store the struct in bytes? How do I read from this? I'm having trouble understanding what I will get back when I use fread</p>