入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

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

创建时间:2016-04-22 投稿人: 浏览次数:645
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];



声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
  • 上一篇:没有了
  • 下一篇:没有了
未上传头像