guys, I want to make a program to generate all combination elements. for example if user input (n) = 3, so the output must be like this :
1
12
123
13
2
23
3
I have a problem to concat integer and string inside recursive function..
Code :
#include <stdio.h>
void rekursif(int m, int n, char angka[100]){
int i;
for(i=m; i<=n; i++){
sprintf(angka, "%s %d", angka, i);
printf("%s \n", angka);
rekursif(i+1,n,angka);
}
}
int main(){
rekursif(1,5,"");
return 0;
}
when I run the program, command prompt is not responding. I guess, the problem is in concation ( sprintf(angka, "%s %d", angka, i); ) please help me to solve this problem. thank you :)