Here is the first part where I read 44 bytes into the array fileName (re-used BTW, as I use it for file name as well). (This code is losely based on Noir´s code in the sticky about development process BTW.)
Code:
// collect data from fileheader in file: fileName.
FILE *fp = fopen( fileName, "r" );
if ( fp ) {
for(i = 0; i < 44; i++) {
fileName[i] = fgetc( fp );
}
fclose( fp );
} else {
perror( "error opening the file" );
}
Here is the part where I memcpy from the array. (it´s just the first struct of three but it should do to demonstrate what happens):
Code:
// Add data to FORM chunk
FormAIFFChunk form = {"FORM", 0, "AIFF"};
memcpy(&form.ckDataSize, &fileName[4], 4);
printf("%s%d%s", form.ckID, form.ckDataSize, form.formType);
OT:
I managed to collect all struct members that I plan to write to (6 in total) in an array BTW, so I might try to somehow automate the assigning from the file in a for loop instead of using the array and memcpy later on.