答案
#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;
}
_daan
1
#include<stdio.h>
int main(void)
{
printf("hello,World!\n");
return 0;
}
课后测试题
0.计算机虽然很快,但他并不聪明,它只懂得0与1的二进制
1.机器语言
2.编译
3.程序执行时,是否需要源代码
4.c语言是编译型语言,跨平台能力并不强,在linux上编译过的程序并不能在windows上运行
5.源文件编译生成中间语言,再通过不同操作系统上的解释器将中间语言翻译成cpu能读懂的机器语言
6.编码与解码
7.亲们趁敌人吃饭时发动进攻
看看
哇
1
感谢楼主
谢谢
1.1和04
4.能
6.对着密码本翻译
7.翻译出来想不出来
做好了!!!!
哈
有答案吗
看答案
1
.
s
{:5_90:}
fishC我来啦