分类: C/C++
2016-01-11 15:07:40
点击(此处)折叠或打开
- #include <stdio.h>
- #include <stdlib.h>
- FILE *f = fopen("textfile.txt", "rb");
- fseek(f, 0, SEEK_END);
- long fsize = ftell(f);
- fseek(f, 0, SEEK_SET);
- char *string = malloc(fsize + 1);
- fread(string, fsize, 1, f);
- fclose(f);
- string[fsize] = 0;