对答案,学习C语言的第一次作业。
123
csasc
f
#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 = ".";
print("计算中...\n");
findALLCodes(path);
findALLDris(path);
printf("目前你总共写了%ld行代码!\n\n",total);
system("pause");
return 0;
}
你好请问一下为什么后面会出现
D:\c语言(小甲鱼)\课1第一个程序\collect2.exe ld returned 1 exit status?
AA
报错了一万个,单词和符号都没错啊,为啥报错呢,就是空格与复制的不太一样,但是又不知道每个打多少个空格{:10_269:}
答案
答案
c
答案
0.无法识别高级语言
1.计算机语言
2.编译
3.解释型语言要先把语言转化为字节码,再发送给解释器进行翻译
4.可以
5.解释器
6.根据莫斯编码表翻译
7.亲们趁敌人吃饭时发动进攻
来看答案了
{:5_109:}
1
nan
1、机器语言2、编译3、解释型:不能生成可独立执行的文件,编译型:目标程序可以脱离其语言环境独立执行
4、能在Windows系统上执行5、通过解释器6、查表
1
课后测试题答案
1
D:\小甲鱼\课后习题