i tried to run it
i cant use global variables
i get an error because there is no array called output.
Code:
#include <stdio.h>
#include <string.h>
void recurse (char *string, int count, int len);
int main() {
char input[255];
char input2[255];
char result[510];
int index,flag,ch;
printf("enter the first string \n");
for (index = 0; index < 254 && (ch = getchar()) != '\n' && ch >=0; ++index)
{
input[index] = ch;
}
input[index] = '\0';
recurse (input, 0, index);
return 0;
}
void recurse (char *string, int count, int len) {
static int i=-1, found=0;
if (i==-1) {i++;recurse(string, 0, len); return;}
if (len==i) return;
if (output[count]==string[i]) { i++;
recurse(string,0,len);
return;}
if (count==found) {output[found]=string[i];
found++; i++;
recurse(string,0,len);
return;}
recurse(string,count+1,len);
}