读取cpp文件处理

代码如下:

#include<Windows.h>
#include<iostream> 
#include<iomanip>
#include<fstream> 
#include<Shlwapi.h>
#include<string>
#include<tchar.h>
using namespace std;

int Filetotalnum=0;//总行数
int avgtotalnum = 0;//各函数平均行数

//链表中的数据结构(函数名字,代码行数)
typedef struct Link_data
{
	int     numline;
	char   Name[20];
	
	//构造函数必须写上
	Link_data() {
	numline = 0;
	memset(Name,0,sizeof(Name));
		}
}Node_data;

//链表节点结构
typedef struct Link_node
{
	Node_data    data;
	struct Link_node  *pNext;
}Node;
//创建链表
Node* CreateList(void)
{
	Node *pHead = NULL;

	//申请的头指针
	pHead = (Node *)malloc(sizeof(Node));

	//判断是否申请成功
	if (NULL == pHead)
	{
		return NULL;
	}

	//针对具体结构进行初始化
	pHead->data.numline = 0;
	memset(pHead->data.Name, 0, 20*sizeof(char));
	pHead->pNext = NULL;

	return pHead;
}
//为每个函数添加一个节点
Node* Insert2ListTail(Node *pHead, Node_data  *pAutoInfo)
{
	Node* pNode = NULL;
	Node* pNewNode = NULL;

	if ((NULL == pHead) || (NULL == pAutoInfo))
	{
		return NULL;
	}

	pNode = pHead;
	while (pNode->pNext != NULL)
	{
		pNode = pNode->pNext;
	}

	pNewNode = (Node *)malloc(sizeof(Node));
	if (NULL == pNewNode)
	{
		return NULL;
	}

	pNode->pNext = pNewNode;
	pNewNode->pNext = NULL;
	memcpy(&(pNewNode->data), pAutoInfo, sizeof(Node_data));

	return pHead;
}
//删除函数链表
int RemoveList(Node *pHead)
{
	Node *pNode = NULL;
	Node *pb = NULL;

	if (NULL == pHead)
	{
		return 0;
	}

	pNode = pHead;
	pb = pNode->pNext;

	if (NULL == pb)
	{
		free(pNode);
	}
	else
	{
		while (NULL != pb)
		{
			free(pNode);
			pNode = pb;
			pb = pb->pNext;
		}
		free(pNode);
	}

	pNode = NULL;

	return 1;
}
//输出每个函数的代码行数
void  outList(Node *pHead)
{
	int sumline = 0;
	int avgline = 0;
	int i = 0;
	Node *pNode = NULL;
	if (NULL == pHead)
	{
		return;
	}

	pNode = pHead->pNext;
	while ((NULL != pNode))
	{
		//printf("\r\n a is %d   b is  %d", pNode->data.a, pNode->data.b);
		sumline = sumline + pNode->data.numline;
		i++;
		cout << "函数" << i << "行数: "<< pNode->data.numline << endl;

		pNode = pNode->pNext;
	}
	avgline = sumline / i;
	avgtotalnum = avgline;
	//cout << "函数总个数: " << i<< "占比:" << nHsP << "%" << endl;
	cout << "函数平均行数: " << avgline<<endl;
	
}
//统计函数个数及行数,占比
void  FunList(Node *pHead)

{
	int sumline = 0;
	int avgline = 0;
	int i = 0;
	Node *pNode = NULL;
	if (NULL == pHead)
	{
		return;
	}

	pNode = p
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值