
// fullpath is a filename with absolute path, dest is a buffer with room for max_chars bytes
// open the file, read in up to max_chars-1 bytes, put in dest, put \0 at end
int read_file(const char *fullpath, char *dest, int max_chars) {
  FILE * f = fopen(fullpath, "r");
  if (f == NULL) return -1;
  int result = fread(dest, 1, max_chars-1, f);
  if (result >= 0) dest[result] = '\0';
  fclose(f);
  return result;
}

char buffer[101];
char * buffer = (char*) malloc(101  * sizeof(char));
read_file("/home/cs473/hello.txt", buffer, 100);