好好学习,天天向上
./test.c: line 10: long: command not found
./test.c: line 12: syntax error near unexpected token `('
./test.c: line 12: `int countLines(const char *filename);'
问下这是怎么了
这是第10到17行
long total;
int countLines(const char *filename);
int isCode(const char *filename);
void findAllDirs(const char *path);
int countLines(const char *filename)
hi
查看答案
看答案
111
111
第一天打卡
打完了
小鱼为什么我只有九行
#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;
}
11
谢谢
嗯嗯嗯嗯会了
。
查看
参考答案
+1
您好,我是Windows系统,为什么我动动手程序运行显示我打了11行代码。
之后我也试了将代码复制,然而还是11行代码。
1. 因为计算机只能识别机器语言
2. 机器语言
3. 编译
4. 编译型语言是将程序编译为汇编语言交由机器执行,而解释型语言通过解释器解释传达给机器
5. 解释型语言因为自带解释器所以可以跨平台运行,也可以在Windows平台运行
6. 摩斯密码的原理是双方约定一个密码本
7. 亲们 趁敌人吃饭时发动进攻