Source

C++ Code:
  1. void kedit(char *file)
  2. {
  3.     int slen;
  4.     int i;
  5.     int result;
  6.     int NUM_SKIP = 40;
  7.     char *sample;
  8.     char tempfile[175];
  9.     FILE *wav;
  10.     FILE *outwav;
  11.    
  12.    
  13.     snprintf(tempfile, 175, "temp%s", file);
  14.     wav = fopen(tempfile, "rb");
  15.     outwav = fopen(file, "wb");
  16.    
  17.     fseek(wav, 0, SEEK_END);
  18.     slen = ftell(wav);
  19.     rewind(wav);
  20.    
  21.     sample = (char*) malloc (sizeof(char)*slen);
  22.     if(sample == NULL)
  23.     {
  24.         fputs("Memory error", stderr);
  25.         exit(1);
  26.     }
  27.    
  28.     result = fread(sample, 1, slen, wav);
  29.     if(result != slen)
  30.     {
  31.         fputs("Read error",stderr);
  32.         exit(2);
  33.     }
  34.    
  35.     fclose(wav);
  36.     char nsample[slen-NUM_SKIP];
  37.     for(i = slen-1; i >NUM_SKIP; i--)
  38.     {
  39.         nsample[i-NUM_SKIP] = sample[i];
  40.         //Some other stuff happens in here too, but it's irrelevant to gettting this all to work.
  41.         printf("nsample: %c", nsample[i]);
  42.         printf(" sample: %c\n", sample[i]);
  43.     }
  44.  
  45.     fwrite(nsample, 1, slen-NUM_SKIP, outwav);
  46.     fclose(outwav);
  47.    
  48.     // return;
  49. }