65,176
社区成员




string a, b;
strcpy(a.c_str(), b.cstr());
string expansion(const string& exp_str, int n)
{
string s = exp_str;
s.append(n, '0');
return s;
}
#include "stdafx.h"
#include <string>
int _tmain(int argc, _TCHAR* argv[])
{
using namespace std;
string a;
a = "123456";
cout << a << endl;
a = "123456789";
cout << a << endl;
return 0;
}
string expansion( string exp_str, int n ) // 把 exp_str 扩大 10^n 倍 后返回结果
{
char r[81];
strcpy( r, exp_str.c_str() );
int np = exp_str.length();
for(int i = 0; i < n; i++)
{
r[np] = '0';
np++;
}
r[np] = '\0';
return r;
}
#include <iostream>
#include <string>
int main()
{
std::string s("Hello World!");
char buf[100];
strcpy(buf, s.c_str());
std::cout << buf << std::endl;
return 0;
}
string.c_str();