出错了。。。
1
来了兄弟们呢
1
的
11111111111111111111111111111111111
测试题
0.只能识别0和1
1.机器语言
2.编译
3.是否为逐行编译执行
4.能
5.逐行编译执行
6.编码与解码
7.亲们趁敌人吃饭时发动进攻
动动手
Input
#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 256
long total;
int countLines(const char *filename);
void findAllCodes(const char *path);
void findAllFiles(const char *path);
int countLines(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)) != EOF)
{
if (temp == '\n')
{
count++;
}
}
fclose(fp);
return count;
}
void findAllCodes(const char *path)
{
struct _finddata_t fa;
long handle;
char thePath, target;
strcpy(thePath, path);
if ((handle = _findfirst(strcat(thePath, "/*.c"), &fa)) != -1L)
{
do
{
sprintf(target, "%s%s", path, fa.name);
total += countLines(target);
}while (_findnext(handle, &fa) == 0);
}
_findclose(handle);
}
void findAllDirs(const char *path)
{
struct _finddata_t fa;
long handle;
char thePath;
strcpy(thePath, path);
if ((handle = _findfirst(strcat(thePath, "/*"), &fa)) == -1L)
{
fprintf(stderr, "The path %s is wrong!\n", path);
return;
}
do
{
if (!strcmp(fa.name, ".") || !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 = ".";
printf("计算中…\n");
findAllCodes(path);
findAllDirs(path);
printf("目前你总共写了 %ld 行代码!\n\n", total);
system("pause");
return 0;
}
Output
计算中…
Can not open the file: .dds.c
Can not open the file: .main.c
The path .bin is wrong!
The path .obj is wrong!
目前你总共写了 0 行代码!
请按任意键继续. . .
Zzz
1
鱼C有你更精彩^_^
0
叮
很不错
小甲鱼你好我用的vs编译器完全照抄的 但是不能调试是什么原因
答案
不知道为什么显示0行
做好了,看看有没有错误
1
做出来了,走了很多弯路
1