如何实现字符串截取阿?解决问题就给分 有字符串str1="下午 11:22:22";我想取出前面两个字符“下午”进行判断,如果是“下午”,就将11加上12,使得str1=“23:22:22”,如果是上午,str1=“11:22:22“怎么样实现阿?大侠帮忙阿! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CString str1="下午 11:22:22";char *szString;szString = str1.GetBuffer(str1.GetLength());szString[4]='\0';if(strcmp(szString,"下午")==0) MessageBox("下午");else MessageBox("上午"); 修改:CString str1="ÏÂÎç 11£º22£º22",str2;str2=str1;char *szString;szString = str2.GetBuffer(str2.GetLength());szString[4]='\0';if(strcmp(szString,"下午")==0) MessageBox("下午");else MessageBox("上午"); // 上面乱码CString str1=="下午 11:22:22",str2;str2=str1;char *szString;szString = str2.GetBuffer(str2.GetLength());szString[4]='\0';if(strcmp(szString,"下午")==0) MessageBox("下午");else MessageBox("上午"); if("上午" == str1.Left(4)){...}else ("下午" == str1.Left(4)){...}else{...} #include<iostream.h>#include<string.h>char st[]="012345678901";void main(){ char str[16]; strcpy(str,"下午 11:22:22"); if(strncmp(str,"下",2)==0) { if(str[5]=='0') str[5]='1'; else str[5]='2'; for(int i=0;i<10;i++) if(str[6]==st[i]) { str[6]=st[i+2];break; } } strcpy(str,str+5); cout<<str<<endl;} Debug和Release下对浮点误差的累积问题 如何在文本编辑工具中实现“打开文件标签”功能? 怎样在vc中调用ACTIVEX控件 ·VC主框架类打开文件编程:GETDOCUMENT cpu的菜问题,最先答对的给分 求解 MoveMemory()怎么用啊 几个关于view函数 请问如何监控系统的端口传输的内容? 【求助】控件设置透明后,背景变成黑色了。 怎样用 IP Address Control? 如何将捕捉到的视频转换为 asf 格式的文件?? FTP服务器测试,免费开放FTP,欢迎上传下载。
char *szString;
szString = str1.GetBuffer(str1.GetLength());
szString[4]='\0';
if(strcmp(szString,"下午")==0)
MessageBox("下午");
else
MessageBox("上午");
CString str1="ÏÂÎç 11£º22£º22",str2;
str2=str1;
char *szString;
szString = str2.GetBuffer(str2.GetLength());
szString[4]='\0';
if(strcmp(szString,"下午")==0)
MessageBox("下午");
else
MessageBox("上午");
CString str1=="下午 11:22:22",str2;
str2=str1;
char *szString;
szString = str2.GetBuffer(str2.GetLength());
szString[4]='\0';
if(strcmp(szString,"下午")==0)
MessageBox("下午");
else
MessageBox("上午");
{
...
}else ("下午" == str1.Left(4)){
...
}
else{
...
}
#include<string.h>
char st[]="012345678901";
void main()
{
char str[16];
strcpy(str,"下午 11:22:22");
if(strncmp(str,"下",2)==0)
{
if(str[5]=='0') str[5]='1';
else str[5]='2';
for(int i=0;i<10;i++)
if(str[6]==st[i])
{
str[6]=st[i+2];break;
}
}
strcpy(str,str+5);
cout<<str<<endl;
}