Why is this code returning wrong answer.
#include
using namespace std;
void seq(char *str,char *out,int i,int j){
///base case
if(str[i]==’\0’){
out[j]=’\0’;
cout<<out<<", ";
return;
}
///recursive case
seq(str,out,i+1,j);
out[j]=str[i];
seq(str,out,i+1,j+1);
}
int main(){
char str[1000];cin>>str;
char out[1000];
seq(str,out,0,0);
}