I am trying to solve a problem which requires me to read a file and generate another file which has the same contents as the original but every fourth byte removed.I tried it doing this way ...
int main()
{
  FILE *p;
  FILE *q;
  int i=0,k=0;
  char c;
  p = fopen("C:\\Users\\Teja\\Desktop\\Beethoven.raw","rw");
  q = fopen("C:\\Users\\Teja\\Desktop\\Beethoven_new.raw","w+");
  printf("%x is the EOF character \n",EOF);
  while((c=fgetc(p))!=EOF)
  {
     if(i==3){
      i=0;
      printf("Removing %x %d \n",c,k++);
     }
     else{
      printf("Putting %x %d \n",c,k++);
      fputc(c,q);
      i++;
     }
  }
  fclose(p);
  fclose(q);
  return 0;
}
The file that i was trying to read is a .raw file and it is around 10-15 MB. I notice that the above code stops reading the file after typically 88 bytes. Is there any way to read large files or am i doing anything wrong ?
 
     
    