Test cases not passed

I think the logic is correct but I am unable to print the answer in the desired format, one extra space and comma is coming, how to remove it.

#include <bits/stdc++.h>
using namespace std;

void print(char* inp,char* out,int i,int j){

if(inp[i]==0){

	out[j]=0;
	cout<<out<<", ";
	return;
}
int a=inp[i]-'0';
if(a==0)return;
if(a>0){
	out[j]='a'+a-1;
	print(inp,out,i+1,j+1);
}
if(inp[i+1]!=0){
	int b=inp[i+1]-'0';
	int no = a*10+b;
	if(no>26)return;
	if(no<1)return;
	out[j]='a'+no-1;
	print(inp,out,i+2,j+1);
}

return;

}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

char s[1000];
cin>>s;   
char ans[1000];
cout<<'[';
print(s,ans,0,0);
cout<<"]";



return 0;

}

the problem with your code is it is also printing a , at end like [abcd, lwd, awd, ] which should not be there.
For solving this problem you can do many thing like you can print that ", " thing before printing the final string, just make sure you don’t do it for the first string by either using a flag variable or a static count variable.

Feel free to ask, if you still didn’t get it.
If you doubt is solved then acknowledge me by marking this doubt as resolved.