@mir no biggie then, on unix we are blessed with stat(2), which you can use to retrieve file information including but not limited to the size of a file
#include <stdio.h> // perror is also here! #include <stdlib.h> // malloc, free #include <unistd.h> // _exit #include <sys/stat.h> #include <string.h> // memset char * cat(char *filename) { FILE *fp; char *buf; struct stat s; if (stat(filename, &s) != 0) { perror("stat"); _exit(-1); } fp = fopen(filename, "r"); if (fp == NULL) { fprintf(stderr, "error: unable to open file\n"); _exit(-1); } buf = malloc(s.st_size+1); memset(buf, s.st_size+1, 0); // fill the buffer with zeroes to ensure null termination // sizeof(char) is always 1 but i like being in the habit of writing these things for portability purposes fread(buf, sizeof(char), s.st_size, fp); fclose(fp); return buf; } int main(int argc, char **argv) { if (argc <= 1) { fprintf(stderr, "error: no file specified\n"); _exit(-1); } for (int i = 1; i < argc; i++) { char *buf = cat(argv[i]); printf("%s", buf); free(buf); buf = NULL; } return 0; }