Hi everyone!
I'm trying to implement my own algorithm for a brute-force program in C but I can't figure out what I'm facing at a certain point. Here's the code:

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define CHUNK 1024


void combinations(char nums[],char candidate[],int current_len,int n3,int len) {

  if(current_len == len) {
      printf("%s\n", candidate);
      return;
  }

  else {
      int i;
      for(i=0; i < n3; i++) {
          candidate[current_len] = nums[i];
          combinations(nums,candidate,current_len+1,n3,len);
        }
  }

 }

int main() {

    // ---- Reading the data from ASCII text ----
    int match[32];
    int length;
    char buf[CHUNK];
    FILE *file;
    size_t nread;
    file = fopen("data.txt", "r");
    if(file) {
      while((nread = fread(buf,1,sizeof buf, file)) > 0) {
        fwrite(buf,1,nread,stdout);
        match[32] = nread;
        length = nread-1;
        printf("\n%d\n", length);
      }

      fclose(file);
    }

    // -------------------------------------------

    char lc_letters[] =   {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v'};
    char up_letters[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V'};
    char nums[] = {'0','1','2','3','4','5','6','7','8','9'};
    char candidate[32];
    char output[32];
    int n = sizeof(lc_letters)/sizeof(lc_letters[0]);
    int n2 = sizeof(up_letters)/sizeof(up_letters[0]);
    int n3 = sizeof(nums)/sizeof(nums[0]);
    int count = length;
    char arr[10] = "";
    char new_str[21];

    combinations(nums,arr,0,n3,count);
}
Now let me explain this: what I'm trying to do is to read the text data from a file (OK here, it works) and then to do all the possible combinations of words or numbers. In this case I just created the combinations of the numbers in order to see if it works with one case and then go on like that with the others, but it's not like that. I can create my combinations with the void function called "combination" but here comes the problem:

  • Now I have both the data text and the combinations created, I can't figure out how to compare the data text with each combination created and print "YES" if it matches or "NO" if it doesn't.

For example: this code reads the data text which is "12", so a text with length 2. Then the program creates all the combinations of numbers from 0 to 9 with length 2, so from 00 to 99.
Now, can someone help me with this? I know it's not one of the best way to implement this algorithm but it's my own idea and I don't want to copy the one of another person.