Reads the contents of a file into a dynamically created character string.
Function Documentation
char*readFile(
FILE*
stream
)
This function reads the contents of a file into a new, dynamically created, character string of the same length as
the file. in the event of an error, this function return a NULL pointer, signalling that no character array was created.
Example:
#include <stdio.h>#include <codecogs/io/binary/read_file.h>usingnamespace IO::Binary;
int main (){FILE* stream = fopen("/Volumes/Data/Components/codecogs/io/binary/read_file.h","rb");
char* data = readFile(stream);
printf("\n %s", data);
fclose(stream);
return0;
}
Parameters:
stream
Returns:
A dynamically allocated string array, containing the file contents