Hi,
I've written the code below which prints every possible combination of the lowercase alphabet for three letters. I'm wondering if anybody knows how I can change this code so it can work with a variable length array? I've been trying to work this out for a while now, it seems pretty tricky.
Thanks.
Code:#include <stdio.h> static const char *s = "abcdefghijklmnopqrstuvwxyz"; static void printarr(const char *arr[], int len) { int i; for(i = 0; i < len; i++) printf("%c", *arr[i]); printf("\n"); } int main() { const char *arr[3]; for(arr[0] = s; *arr[0] != '\0'; arr[0]++) { for(arr[1] = s; *arr[1] != '\0'; arr[1]++) { for(arr[2] = s; *arr[2] != '\0'; arr[2]++) { printarr(arr, 3); } } } return 0; }