假设有个字符数组bufPohne
char bufPohne[2100] = "111;222;333;444"; //字符串数组,里面存储的数字字符以分号隔开另外有数组bufRecv
char bufRecv[4096];我想bufRecv中的字符如下格式: "The number is:111 The number is:222 The number is:333 The number is:444"
其中111,222,333,444为bufPohne中分离出来的字符串这应该如何处理,希望高手指点 谢谢
char bufPohne[2100] = "111;222;333;444"; //字符串数组,里面存储的数字字符以分号隔开另外有数组bufRecv
char bufRecv[4096];我想bufRecv中的字符如下格式: "The number is:111 The number is:222 The number is:333 The number is:444"
其中111,222,333,444为bufPohne中分离出来的字符串这应该如何处理,希望高手指点 谢谢
解决方案 »
- ListCtrl控件中已添加了一些图标,现想用鼠标点击图标,产生事件。如何实现?
- 在VC里面,为什么不能够loadlibrary运行库函数
- 【分享】VC++调用大漠插件多线程实例
- 如何实现在DHTML Edit控件中插入Flash或者视频等对象,请高手指教!!!!!!!!!!!
- arc、arcto划线函数如何使用?
- 不懂广播,请给我讲讲行吗?
- 关于win32下dll的调用问题
- 请教高手,关于vc程序运行时用到的几个动态链接库。
- VC初学者在串口通信的程序中遇到的问题:串口通信中使用重叠方式(Overlapped)进行I/O操作的好处?
- file.Open(filename,CFile::modeCreate|CFile::typeBinary|CFile::modeWrite)
- windows网络编程中overlapped这个地方是不是弄错了
- 跟踪条控件的控制消息
{
char tmpchar = str1.GetAt(i);
if((tmpchar==';')||(i==0))
{
CString str2;
if(i==0)
str2="The number is:"+str1.Mid(i,3);
else
str2="The number is:"+str1.Mid(i+1,3);
MessageBox(str2);
}
}
不过char bufPohne[2100] = "111;222;333;444"; 中的数字字符不一定是定长的。
比如有可能是char bufPohne[2100] = "111;2222;33;4444444";
CSting strBufPohne = bufPohne;
CString strTmp = _T(";") + strBufPohne;
strTmp.Replace(_T(";"), _T(" The number is:"));
然后再把strTmp中的内容填回到bufRecv中
char bufRecv[4096];
CString cstr1 = (char*)bufPohne;
CString cstr2;
int a;
for(;;)
{
a= cstr1.Find(';');
if( a == -1 )break;
cstr2 += _T(" The number is:") + cstr1.Left(a);
cstr1 = cstr1.Right(cstr1.GetLength() - a - 1);
}
strcpy((char*)bufRecv,cstr2);