我想将函数返回的数组存储到函数外部的新数组中。
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char* ReduceString(char *s, char *s2)
{
int n=strlen(s);
sort(s,s+n);
int count=1,j=0;
for(int i=0;i<n;i++)
{
if(s[i]==s[i+1])
{
count++;
}
else if((count)%2==1 && count>=2)
{
s2[j]=s[i];
count=1;
j++;
}
else if(count%2==0)
{
count=1;
continue;
}
else
{
s2[j]=s[i];
continue;
j++;
}
}
return s2;
}
int main()
{
string s;
getline(cin,s);
char s2[100];
**///**I want to store the value returned here into code****
return 0;
}
我想将返回的数组s2
存储到一个新数组中,以便我可以使用它。
在c ++中可以吗?