Ok here's what I got so far.
This is only for base 2.
Code:
#include <stdio.h>
#include <ctype.h>
#include <string.h>
// test generate base 2
int main() {
char base[16][3];
char temp[3];
char choice[] = "acgt";
int i, j, k = 0;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
sprintf(temp, "%c%c\0\n", choice[i], choice[j]); //save the string to temp
strcpy(base[k],temp); // save each occurrence
k++;
}
}
for (i = 0; i < 16; i++)
printf("%s \n", base[i]);
return 0;
}
And the output is:
Code:
aa
ac
ag
at
ca
cc
cg
ct
ga
gc
gg
gt
ta
tc
tg
tt
Note: the reason why I saved the occurrences permanently in an array (base) instead of printing it right away (from temp) is because I'm planning on doing something to each of the occurrence later.
The problem is, for each base number, the char base[16][3] and char temp[3] changes in number (ie, for base 3, it would have to be char base[64][4] and char temp[4]. And, the more bases, the more for loops (ie. base 2 has 2 for loops, base 3 would have 3 for loops, etc.).
So,
1) How should I make it a separate method instead of residing inside main()? What should the prototype method be?
2) How should I make the method works for any base number (without repeatedly typing the same codes 15 times and only adding an additional for loop for each base)?
P.S. I plan on avoiding continue, skip, break, etc. They're just not my style.