Reads the contents of a file into a dynamically created character string.

View versions (1)

Interface

#include <codecogs/computing/io/binary/read_file.h>

using namespace Computing::Io::Binary;

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/computing/io/binary/read_file.h>

using namespace Computing::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);

  return 0;
}

Returns

A dynamically allocated string array, containing the file contents
GPL Licence — free for non commercial use. See Licence details.