统计一个项目的代码行数,只统计cpp文件
2008-12-30 18:33
846 查看
#include <iostream>
#include <fstream>
#include <direct.h>
#include <io.h>
#include <string>
#include "my_dll1.hpp"
using namespace std;
int countLine(char *filename);
void countBrowseLine(char *pathName, char *filetype);
int main(int argc, char *argv[])
{
if (*(argv+1)==NULL || *(argv+2)==NULL )
{
return 0;
}
char str[50];
strcpy(str,*(argv+1));
char type[20];
strcpy(type,*(argv+2));
countBrowseLine(str,type);
system("pause");
return 0;
}
void countBrowseLine(char *pathName,char *filetype)
{
_chdir(pathName);
_finddata_t fdata;
int nTotal = 0;
int n = 0;
long label = _findfirst(filetype,&fdata);
do
{
cout << "the lines of the " << fdata.name << " is ";
n = countLine(fdata.name);
nTotal += n;
cout << n << endl;
} while (_findnext(label,&fdata) == 0);
cout << "all the lines of the browse about "<< filetype<<" is " << nTotal << endl;
}
int countLine(char *filename)
{
int nCount = 0;
fstream fin(filename);
char c[300];
if (!fin)
{
cout << "读取文件错误"<< endl;
return 0;
}
while (!fin.eof())
{
fin.getline(c,300);
++nCount;
}
fin.close();
return nCount;
}
#include <fstream>
#include <direct.h>
#include <io.h>
#include <string>
#include "my_dll1.hpp"
using namespace std;
int countLine(char *filename);
void countBrowseLine(char *pathName, char *filetype);
int main(int argc, char *argv[])
{
if (*(argv+1)==NULL || *(argv+2)==NULL )
{
return 0;
}
char str[50];
strcpy(str,*(argv+1));
char type[20];
strcpy(type,*(argv+2));
countBrowseLine(str,type);
system("pause");
return 0;
}
void countBrowseLine(char *pathName,char *filetype)
{
_chdir(pathName);
_finddata_t fdata;
int nTotal = 0;
int n = 0;
long label = _findfirst(filetype,&fdata);
do
{
cout << "the lines of the " << fdata.name << " is ";
n = countLine(fdata.name);
nTotal += n;
cout << n << endl;
} while (_findnext(label,&fdata) == 0);
cout << "all the lines of the browse about "<< filetype<<" is " << nTotal << endl;
}
int countLine(char *filename)
{
int nCount = 0;
fstream fin(filename);
char c[300];
if (!fin)
{
cout << "读取文件错误"<< endl;
return 0;
}
while (!fin.eof())
{
fin.getline(c,300);
++nCount;
}
fin.close();
return nCount;
}
相关文章推荐
- C++ 一个统计文件夹下所有代码文件行数的小工具
- 小脚本,统计一个目录下满足特定条件文件的代码行数
- 发一个统计项目代码行数的Java代码
- Atitit.Gui按钮与面板---项目规模的评估----文件数统计,结构,代码行数,每类型文件行数.
- Atitit.Gui按钮与面板---项目规模的评估----文件数统计,结构,代码行数,每类型文件行数.
- Java代码 统计项目的文件数量,和代码行数
- 统计文件夹内.c .cpp .py类型文件的代码行数
- 一个用shell写的统计目录下统计文件行数的代码
- 统计项目下Java文件数及代码行数
- Atitit.Guibutton与面板---项目规模的评估----文件数统计,结构,代码行数,每类型文件行数.
- [2017.02.13] linux平台下统计C++项目文件个数和代码行数
- VS统计项目总代码行数
- 给定一个Java文件,统计文件中的代码行
- 递归统计项目中的非空白代码行数
- Visual Studio中如何统计怎个项目的代码行数
- 使用shell脚本统计各个模块每个文件代码行数与总行数
- linux下如何统计一个目录下的文件个数以及代码总行数的命令
- 如何统计一个文件的行数
- 一条shell指令统计项目的代码行数
- 第七章:输入与输出,给定一个源代码文件(.cs, .java),输出该文件的总行数、空行数、注释行数、代码行数。