。
1
。
让我康康
回复
查看参考答案
1
1
2022/6/14 第一次看课打卡~
运行时权限不够怎么解决
1
#include<io.h>
#include<direct.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX256
long total;
//ok
int coutLines(const char *filename);
void fileAllCodes(const char *path);
void fileALLFiles(const char *path);
int coutLines(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;
}
//yes
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 +=coutLines(target);
}while(_findnext(handle,&fa)==0);
}
_findclose(handle);
}
//yes
void findALLDirs(const char *path)
{
struct _finddata_t fa;
long handle;
char thePath;
//yes
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;
//yes
if(fa.attrib == _A_SUBDIR)
{
sprintf(thePath,"%s/%s",path,fa.name);
findAllCodes(thePath);
findALLDirs(thePath);
}
}while(_findnext(handle,&fa)==0);
_findclose(handle);
}
//yes
int main(){
char path =".";
printf("计算中...\n");
findAllCodes(path);
findALLDirs(path);
printf("目前你总共写了%ld 行代码!\n\n",total);
system("pause");
return 0;
}
目前你已经写了99行代码
22
查看参考答案
iOS上的c语言怎么会报错啊
iOS端的c语言程序直接报错了
shocheng
1
亲们,陈地人拆凡是发东仅共
看答案