牛骨文教育服务平台(让学习变的简单)
博文笔记

C++ 动态申请数组的一个Demo

创建时间:2016-04-22 投稿人: 浏览次数:995
void CDeleteDirTestDlg::OnBnClickedBtnTest()
{

	//3,7,20,31
	CString strBandDetails=_T("");
	int iNum=4;
	int *pV=new int[iNum];
	CString strBandDetails2=_T("3,7,20,31");
	for (int i=0;i<iNum;i++)
	{
		CString strTemp=_T("");
		int t=strBandDetails2.Find(",");
		if (-1 !=t)
		{
			int band0=atoi(strBandDetails2.Left(t));
			if (band0<10)
			{
				strTemp.Format(_T("0%d"),band0);
			}
			else
			{
				strTemp.Format(_T("%d"),band0);
			}
			pV[i]=band0;
			strBandDetails=strBandDetails+strTemp;
		}
		else
		{
			int band1=atoi(strBandDetails2);
			if (band1<10)
			{
				strTemp.Format(_T("0%d"),band1);
			}
			else
			{
				strTemp.Format(_T("%d"),band1);
			}
			pV[i]=band1;
			strBandDetails=strBandDetails+strTemp;
		}		
		strBandDetails2=strBandDetails2.Mid(t+1,strBandDetails2.GetLength());
	}

	CString s=strBandDetails;

}


int *pV=new int[iNum];
扩展一下 type *pV=new type[iNum];



声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。