#include <stdio.h>
#include <stdlib.h>
int main()
{
char file[100] = "d:\\data.txt";
char *buf;
FILE *fp = fopen(file, "r");
fseek(fp, 0L, SEEK_END);
int fsz = ftell(fp);
fseek(fp, 0L, SEEK_SET);
buf = (char *) malloc(sizeof(char) * (fsz + 1));
if (buf == NULL) {
puts("malloc error");
fclose(fp);
exit(EXIT_FAILURE);
}
fread(buf, sizeof(char), fsz, fp);
fclose(fp);
buf[fsz - 1] = '\0';
printf("%s\n", buf);
free(buf);
return 0;
}
/*
run:
c c++ c#
java python
*/