您当前的位置: 首页 >  c++

txwtech

暂无认证

  • 3浏览

    0关注

    813博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

c++ strlen(),GetLength(),sizeof()用法与区别

txwtech 发布时间:2019-12-12 22:44:01 ,浏览量:3

int startstr_count=startStr.GetLength();//统计cstring类型的长度     int startstr_count1=strlen(mapname_aac);//统计char数组类型的长度     int startstr_count1=sizeof(startStr);//是用来计算变量或者对象、类型所占字节的多少

void CgetMappingNo1Dlg::OnBnClickedButton1()
{
	// TODO: 在此添加控件通知处理程序代码
	CString ocrChars(_T("abde#8.txt"));
	/*char mapname_number_before_char[41]="de#";
	char mapname_number_after_char[41]= _T(".");*/

	char mapname_aac[1024]={"abcdefg"};

	CString startStr = _T("abde#");  
	CString startStr1 = _T("#"); 
	CString startStr2 = _T("abcd"); 
	CString endStr = _T("."); 
	int iPlaceStart = 0;
	int iPlaceEnd = 0;
	CString strMapNo;
	      //abde#8.txt, mid--子字符串中的第一个字符的从零开始的索引- abde#, 5,6-5=1
           //#, 4+1,6-1
          gabde#8.txt
		iPlaceStart = ocrChars.Find(startStr); //4
		//ocrChars.Delete(0, iPlaceStart+strlen(startStr));
		int startstr_count=startStr.GetLength();//统计cstring类型的长度	
		int startstr_count1=strlen(mapname_aac);//统计char数组类型的长度	
        int startstr_count1=sizeof(startStr);//是用来计算变量或者对象、类型所占字节的多少
		ocrChars.Delete(0, iPlaceStart+sizeof(startStr)-1);

		iPlaceEnd = ocrChars.Find(endStr);   //7  abde#18.txt
		/*if (-1 != iPlaceStart && -1 != iPlaceEnd && iPlaceStart < iPlaceEnd)
		{
		  strMapNo = ocrChars.Mid(iPlaceStart+strlen(startStr), iPlaceEnd-strlen(startStr));
		}*/
		if (-1 != iPlaceStart && -1 != iPlaceEnd)
		{
			strMapNo = ocrChars.Left(iPlaceEnd);
		}
	      
		
		if(strMapNo==strMapNo.SpanIncluding(_T("0123456789")))//判断是否全是数字,如果有字母就不转换txw
		{
			CString string = _T("between two chars mapping No. is: ");
			string += strMapNo;
			MessageBox(string);
			//return(_ttoi(strMapNo));//字符转整型
		}
		else
		{
			//AfxMessageBox(_T("ocr所提取片号错误,当前提取为: ")+strWaferNo, MB_ICONSTOP | MB_OK | MB_TOPMOST);
			AfxMessageBox(_T("between two chars mapping所提取片号错误,当前提取为: ")+strMapNo);
			CString string = _T("between two chars wrong mapping No. is: ");
			string += strMapNo;
			MessageBox(string);
			//ModifyMessageLog_Error(string);
		}
	

}

 

关注
打赏
1665060526
查看更多评论
立即登录/注册

微信扫码登录

0.0410s