【发布时间】:2020-03-18 01:00:02
【问题描述】:
本质上,这是我的问题。
FILE *fp = "/my/textfile/location";
fseek(fp, 0L, SEEK_END);
int size = ftell(fp);
char *output_string[size];
printf("%d", size); // gives me 25
printf("%ld", sizeof(output_string)); // gives me 200.
为什么当 ftell 返回的 int 是 20 时 sizeof(output_string) 给我 200?
【问题讨论】:
-
200 == 25*8。 8 == sizeof(char*).
-
Jules - “如何 [动态] 声明 char 数组”可能有重复...如果您已经知道它只是“印刷错误”...
-
char* 数组不是 char 数组。
-
你的意思是 *output_string[size] 是在创建一个指针数组吗?
-
FILE *fp = "/my/textfile/location";-- 为你编译的?