|
下面是修改的详细方法(我用”explorer.exe”作为例子修改)
1、
#include //加一个头文件
/*……*/
char *str1,*str2,*str3,*str4;
strcpy (str1,”exp”); //复制”exp”到str1
strcpy (str2,”plorer”);
strcpy (str3,”exe”);
strcat (str1,str2); //将str2连接到str1后
strcat (str2,str3);
strcpy (str4,str3); //str4值为”explorer.exe”
2、
#include //加一个头文件
using namespace std; //声明名空间
/*……*/
string *str1,*str2,*str3;
str1.assign (”explo”); //复制”explo”到str1
str2.assign (”rer.exe”);
str1.append (str2); //将str2连接到str1后
str3.assign (str1); //str3值为”explorer.exe”
3、
#include //加一个头文件
using namespace std; //声明名空间
/*……*/
string *s1=”abcexplorer.exekgh”;
s1.substr(3,12); //3为从第三个字节开始读取,12为读取12个字符
4、
#include //加一个头文件
using namespace std; //声明名空间
/*……*/
string *s1=”ex.exe”;
string *s2=”plorer”;
s1.insert(2,s2); //在第2个字节后插入s2的值
5、
#include //加一个头文件
using namespace std; //声明名空间
/*……*/
string *s1=”explorer.exe”;
string *s2=”ip.tet”
s1.swap (s2); //交换s1与s2的值,s2值为”explorer.exe” |
|