void reversefunction( const char *argv2, const char *argv3){
FILE *stream1=NULL;
FILE *stream2=NULL;
byteone table[HEADERLENGTH];
byteone numberofchannels;
byteone movebytes;
bytefour i;
bytefour sizeofdata;
bytefour var_towrite_infile;
stream1=fopen(argv2,"rb");
stream2=fopen(argv3,"wb+");
if(stream1==NULL){
printf("\n.xX!- failed - to - open - file -!Xx.\n");
exit(0);
}
if(stream2==NULL){
printf("\n.xX!- failed - to - create - new - file -!Xx.\n");
exit(0);
}
printf(".xX!- %s - opened - success -!Xx.\n",argv2);
fread(table,1,HEADERLENGTH,stream1);
//here starts the problem
numberofchannels=little_endian_to_bytefour((table+22),NUMCHANNELS);
sizeofdata=little_endian_to_bytefour((table+40),SUBCHUNK2SIZE);
//here ends the problem
fwrite(table,1,HEADERLENGTH,stream2);
movebytes=numberofchannels*2;
i=sizeofdata;
fseek(stream1,i,SEEK_SET);
while(i>=0){
fread(&var_towrite_infile,4,movebytes,stream1);
fwrite(&var_towrite_infile,4,movebytes,stream2);
i=i-movebytes;
fseek(stream1,i,SEEK_SET);
printf("%d\n",i);
printf("%d\n",sizeofdata);
printf("%d\n",little_endian_to_bytefour((table+40),SUBCHUNK2SIZE));
printf("-------------\n");
}
fclose(stream1);
fclose(stream2);
return;
}
So, when i'm trying to pass in variables numberofchannels and sizeofdata the return value of function little_endian_to_bytefour it doesn't pass nothing.And when i print the return value, it prints it correct. So why this happens ?
//screen of terminal
.
.
.
0
0
113920
-------------
0
0
113920
-------------
0
0
113920
-------------
.
.
.
//end of screen terminal
//additional imformation
typedef unsigned char byteone;
typedef unsigned short int bytetwo;
typedef unsigned int bytefour;
bytefour little_endian_to_bytefour(byteone *table, byteone bit_length){
bytefour number=0;
if(bit_length==2){
number=table[1];
number<<=8;
number|=table[0];
}
else{
number=table[3];
number<<=8;
number|=table[2];
number<<=8;
number|=table[1];
number<<=8;
number|=table[0];
}
return number;
}
small example/*
int myfunction(int var1, int var2)
{
int var3;
var3=var1+var2
return var3;
}
int main(void){
int zaza1;
zaza1=myfunction(2,3);
printf("the number is %d",zaza1);
return;
}
//terminal
the number is 0
//end of terminal
*/