title: C - Linux Sparse File: How to check if file is sparse and print 0-filled disk blocks
body: <p>What I am trying to do is to write a C program on linux which should be checking in the current directory if there are sparse files, and also I would like to print the number of disk blocks that already represent gaps in the file and the number of disk blocks that are 0-filled but take up disk space.</p>
  
  <p>So far I can access the current directory and print just the files with</p>
  
  <pre><code>DIR *dirp;
  struct dirent *dp;
  </code></pre>
  
  <p>To get done the second part with sparse file I tried to use <code>stat()</code> but it seems not to be working because I don't get the required results as I wished.</p>
  
  <p>So, could anyone show me how to do the part with the sparse file?</p>