。
[此贴子已经被作者于2020-3-14 13:52编辑过]
for (p = &str[m - 1]; p <= &str[n - 1]; p++) str1.push_back(*p);
void Partial_replication(string str) { int StringLength(string str); string str1 = str; int n, m, i = 0; char *p, *p1; n = StringLength(str); cout << "请输入被复制的字符个数m,(m<" << n << "):"; cin >> m; for (p = &str[m - 1], p1 = &str1[0]; p <= &str[n - 1];) *p1++ = *p++; while(*p1)*p1++ = 0; cout << "被复制的部分字符串为:" << str1 << endl; }
[此贴子已经被作者于2020-3-14 01:52编辑过]