C - able to read an EVP encrypted file but when I store it in a char array, everything disappears -
i have evp encrypted file want send on socket. however, realised nothing being sent because seems nothing stored in array read file into, sure there stored since able decrypt after reading file. the code snippet below part boggling me. file *fp; long lsize; fp = fopen ( evp_file , "rb" ); fseek(fp, 0l, seek_end); int fsize = ftell(fp); fseek(fp, 0l, seek_set); unsigned char *indata = malloc(fsize); fread(indata,sizeof(char),fsize, fp); printf("%s\n", indata); // printing indata returns me nothing @ //then decryption //decrypting indata works! , want. as commented, no output when print indata. there doing wrong here? need store in array can send on socket. ps. when use plain text file, works fine. thanks in advance!! if it's text data ( ascii characters, perhaps utf-8, not binary ) need nul terminate buffer, add 1 byte malloc() ed size , then indata[fsize] = '\0'; ...