65,186
社区成员




#include <string>
#include <iostream>
using namespace std;
void main()
{
string mya("5-");
string temp="";
for(int i =0 ;i<5;i++)
{
char a[10];
string str;
itoa(i, a, 10);
str = a;
temp = mya+a+",";
printf("%s",temp.c_str());
}
}
#include <string>
#include <iostream>
using namespace std;
string g_str = "";
int main()
{
string mya("5-");
string temp="";
for(int i =0 ;i<5;i++)
{
char a[10];
string str;
itoa(i, a, 10);
str = a;
// temp = mya+a+",";
temp = mya + a;
if (i != 4)
temp += ",";
// printf("%s",temp.c_str());
g_str += temp; // 连到全局变量里
// 输出不输出就看你自己想不想这么干了,变量放在g_str里了
cout << g_str << endl;
}
getchar(); // 程序停顿用
return 0;
}
char *p = const_cast<char*>(str1.c_str());
const char *pp = "5-5";
strcat(p, pp);
printf("%s",p);
#include <string>
#include <iostream>
using namespace std;
void main()
{
string mya("5-");
string temp="";
string str1="";
for(int i =0 ;i<5;i++)
{
char a[10];
itoa(i, a, 10);
temp = mya+a+",";
str1 = str1 + temp;
}
string str2="5-5";
str2=strcat(str1,str2)
printf("%s",str2.c_str());
}
string str2="5-5";
str2=strcat(str1,str2);//字符串直接相加就好。。。
//临时写的
int main()
{
string mya("5+");
string temp="";
char** Src =new char*[20];
for(int nIndex = 0; nIndex < 20; ++nIndex)
{
Src[nIndex] = new char [20];
strcpy(Src[nIndex],"");
}
for(int i =0 ;i<6;++i)
{
char a[10];
string str;
itoa(i, a, 10);
str = a;
temp = mya+a+",";
strcat(Src[i],temp.c_str());
}
for(int i =0 ;i<6;++i)
{
printf("%s\n",Src[i]);
}
delete []Src;
system("pause");
return 0;
}
string mya("5-");
string temp="";
string str1="";
for(int i =0 ;i<5;i++)
{
char a[10];
itoa(i, a, 10);
temp = mya+a+",";
str1 = str1 + temp;
}
string str2="5-5";
str2=strcat(str1,str2);
//str2=str1+str2;
printf("%s",str2.c_str());