How can i send example.wav file bytes encoded base64 via UNIX socket?
char* readFileBytes(const char *name){
FILE *fl = fopen(name, "rb");
fseek(fl, 0, SEEK_END);
long len = ftell(fl);
char *ret = malloc(len);
fseek(fl, 0, SEEK_SET);
fread(ret, 1, len, fl);
fclose(fl);
return ret;
}
This is my read from file. Now i need to get string or something from this array, because i need to encode, and when i try to:
printf("%s\n", ret);
Output: RIFF�3
program encodes only that RIFF�3.
I can do cycle
for(int i=0; i<len;i++){printf("%u ",ren[0])}
Then i get something more intresting, but still, how can i encode whole binary array. Later i will send encoded string via UNIX socket, but that's not the case ATM.
EDITED:> I use http://fm4dd.com/programming/base64/base64_stringencode_c.htm algorithm for encoding. Is it wrong for binary?