//Function: 计算文件字符数 #include<stdio.h> int main(int argc, char *argv[]) { FILE *fp; if(argc != 2) { printf("Usage:%s [file name]/n", argv[0]); return 0; } fp = fopen(argv[1], "r"); if(fp == NULL) { perror("Open file"); return 0; } fseek(fp, 0, SEEK_END); printf("file %s length:%ld Bytes/n", argv[1], ftell(fp)); return 0; }