I'll not give you complete source code. Even though it's not homework, i'm convinced you'll learn more by finding out yourself ...
Here's some pointers to get you started :
How about passing a char array (or pointer) that contains the string uptill now ? ie. the following call chain :
main()
tf("", 3)
tf("T", 2)
tf("TT", 1)
printf("TTT")
printf("TTF")
tf("TF", 1)
printf("TFT")
printf("TFF")
tf("F", 2)
tf("FT", 1)
printf("FTT")
printf("FTF")
tf("FF", 1)
printf("FFT")
printf("FFF")
I'd be happy to take a look at any code you make and give further pointers !
Main Topics
Browse All Topics





by: amit_gPosted on 2006-01-22 at 14:00:20ID: 15762197
#include <stdio.h>
void ouputCombos(int HowMany, char* Combo)
{
if (HowMany == 0)
{
printf("%s\n", Combo);
return;
}
HowMany--;
Combo[HowMany] = 'T';
ouputCombos(HowMany, Combo);
Combo[HowMany] = 'F';
ouputCombos(HowMany, Combo);
}
int main()
{
const MAX_CHARS = 10;
int HowMany = 3;
char Combo[MAX_CHARS + 1];
Combo[HowMany] = '\0';
ouputCombos(HowMany, Combo);
return 0;
}