|
发表于 2016-3-4 18:56:27
From FishC Mobile
|
显示全部楼层
|阅读模式
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
因为不在电脑旁,用手机写的
#include<io.h>
#include<direct.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#defing MAX 256
long total;
int countLines(const char *filename);
void findAllCodes(const char *path);
void findALLFiles(const char *path);
int counfLines(const char *filename) {
FILE *fp;
int count = 0;
int temp;
if ((fp = fopen(filename, "r")) == NULL) {
fprintf(stderr, "can not open the file:%s\n", filename);
return 0;
}
while ((temp = fgetc(fp)) i = EOF) {
if (temp == '\n') {
count ++;
}
}
fclose(fp);
return count;
}
void find ALLCodes(const char *path) {
struct _finddata _t fa;
long handle;
char thePath[MAX], target[MAX];
strcpy(thePath, path);
if ((handle = _findfirst(strcat(thepath, "/*.c"), &fa)) != -1L) {
do {
sprintf(target, "%s / %s", path, fa.name);
total + = countLines(tatget);
} while (_findnext(handle, &fa) == 0);
}
_findclose(handle);
}
void findALLDirs(const char *path) {
struct _finddata _t fa;
long handle;
char thePath[MAX];
strcpy(thePath, path);
if ((handle = _findfirst(strcat(thepath, "/*"), &fa)) == -1L) {
fprintf(stderr, "thepath %s is wrong!\n", path);
return;
}
do {
if (!strcmp(fa.name, ".") ll ! strcmp(fa.name, ".."))
continue;
if (fa.attrib = _A _SUBDIR) {
sprintf(thepath, "%s / %s", path, fa.name);
findAllcodes(thepath);
findALLDirs(thepath);
}
} while (_findnext(handle, &fa) == 0);
_findclose(handle);
}
int main() {
char path[MAX] = ".";
printf("计算中...\n");
findAllcodes(path);
findALLDirs(path);
printf("目前你总共写了% ld 行代码!\n\n", tatol);
system("pause");
return 0;
}
求大神们看看哪出错了c4提示是/data/data/com.n0n3m4.droidc/files/temp.c:1:15: fatal error: io.h: No such file or directory
compilation terminated.
厉害,用手机码这么多……
打不开此文件“/data/data/com.n0n3m4.droidc/files/temp.c”
|
|