I tried to read binary files into dinamic string and somthing go wrong. I cant set free the string and i cant print or do anything else with it. The files are OK if I just open it without all the dinamic stuff it runs well.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma warning (disable: 4996)
#define STR_LEN 50
int main(int args, char** argv)
{
char filePath[STR_LEN];
char signaturePath[STR_LEN];
FILE* file;
FILE* signature;
int fileSize;
int signatureSize;
strcpy(filePath, argv[2]);
strcpy(signaturePath, argv[1]);
file = fopen(filePath, "rb");
signature = fopen(signaturePath, "rb");
if (file == NULL)
printf("e: f\n");
if (signature == NULL)
printf("e: s\n");
fseek(file, 0L, SEEK_END);
fileSize = ftell(file);
fseek(file, 0L, SEEK_SET);
fseek(signature, 0L, SEEK_END);
signatureSize = ftell(signature);
fseek(signature, 0L, SEEK_SET);
char* fileStr = (char)malloc(sizeof(char) * fileSize + 1);
char* signatureStr = (char)malloc(sizeof(char) * signatureSize + 1);
fread(fileStr, fileSize, 1, file);
fread(signatureStr, signatureSize, 1, signature);
free(fileStr);
free(signatureStr);
fclose(file);
fclose(signature);
return 0;
}