Files
Linux-C-Notes/Chapter13/io/stdio/flen.c
2024-04-27 00:22:26 +08:00

28 lines
375 B
C

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
FILE *fp;
if (argc < 2)
{
fprintf(stderr, "Usage...\n");
exit(1);
}
fp = fopen(argv[1], "r");
if (NULL == fp)
{
perror("fopen()");
exit(1);
}
fseek(fp, 0, SEEK_END);
printf("%d\n", ftell(fp));
fclose(fp);
exit(0);
}