I have to copy first 64 bytes from input file in.wav into output file out.wav. (I've downloaded a program which shows .wav file's header (chunks): first 44 bytes and first 20 bytes of data_subchunk)
My code fills out.wav file with some values, but (I'm convinced) it to be a garbage. (The values that program shows don't match.)
I have to copy a part of in.wav file into out.wav:
#include <stdio.h>
#include <stdlib.h>
typedef struct FMT
{
char Subchunk1ID[4];
int Subchunk1Size;
short int AudioFormat;
short int NumChannels;
int SampleRate;
int ByteRate;
short int BlockAlign;
short int BitsPerSample;
} fmt;
typedef struct DATA
{
char Subchunk2ID[4];
int Subchunk2Size;
int Data[441000]; // 10 secs of garbage. he-he)
} data;
struct HEADER
{
char ChunkId[4];
int ChunkSize;
char Format[4];
fmt S1;
data S2;
} header;
int main()
{
FILE *input = fopen("in.wav", "r");
FILE *output = fopen("out.wav", "w");
if(input == NULL)
{
printf("Unable to open wave file\n");
exit(EXIT_FAILURE);
}
fwrite(&input, sizeof(int), 16, output); // 16'ints' * 4 = 64 bytes
fclose(input);
fclose(output);
return 0;
}
What is wrong?