I'm starting to do things in C, because it gets a lot of attention this language. I did a word generator with numbers and letters mixed. The words are of length 8 and contain specific characters.
I ask for help because I have done the code that generates the words correctly, and every 20,000 words generated saves the last word in txt, and when you start it, it detects that word and displays it in console.
What I like to do is get that last word and send it to cycle to cycle, if any word, start of the word, not the beginning.
Here you have the code and thank you in advance to anyone who can offer help.
#include <stdio.h>
#include <stdlib.h>
int main(int main, char *argv[]){
int a,b,c,d,e,f,g,h;
char var0[] = {'1','A','2','B','3','C','4','D','5','E','6'};
char var1[] = {'1','A','2','B','3','C','4','D','5','E','6'};
char var2[] = {'1','A','2','B','3','C','4','D','5','E','6'};
char var3[] = {'1','A','2','B','3','C','4','D','5','E','6'};
char var4[] = {'1','A','2','B','3','C','4','D','5','E','6'};
char var5[] = {'1','A','2','B','3','C','4','D','5','E','6'};
char var6[] = {'1','A','2','B','3','C','4','D','5','E','6'};
char var7[] = {'1','A','2','B','3','C','4','D','5','E','6'};
char caracteres[9];
FILE *fp, *sesion;
sesion = fopen("Save_Sesion.txt","r");
if (sesion == NULL){
printf("\nNo Sesion.\n");
}
else{
printf("\nLast key was:\n\n");
while (feof(sesion) == 0){
fgets(caracteres,9,sesion);
printf("%s",caracteres);
}
}
printf("Press any key to continue\n");
getchar();
for( a=0; a <= 10; a++){
for( b=0; b <= 10; b++){
for( c=0; c <= 10; c++){
for( d=0; d <= 10; d++){
for( e=0; e <= 10; e++){
for( f=0; f <= 10; f++){
for( g=0; g <= 10; g++){
for( h=0; h <= 10; h++){
printf("%c%c%c%c%c%c%c%c\n",var0[a],var1[b],var2[c],var3[d],var4[e],var5[f],var6[g],var7[h]);
}
}
}
}
fp = fopen("Save_Sesion.txt","w");
fprintf(fp, "%c%c%c%c%c%c%c%c\n",var0[a],var1[b],var2[c],var3[d],var4[e],var5[f],var6[g],var7[h]);
fclose(fp);
}
}
}
}
return 0;
}