我开始用 C 做事,因为它引起了这种语言的很多关注。我做了一个混合了数字和字母的单词生成器。单词长度为 8,包含特定字符。
我请求帮助是因为我已经完成了正确生成单词的代码,并且每生成 20,000 个单词就会将最后一个单词保存在 txt 中,当你启动它时,它会检测到该单词并在控制台中显示它。
我喜欢做的是获取最后一个单词并将其发送到循环到循环,如果有的话,是单词的开头,而不是开头。
在这里你有代码,并提前感谢任何可以提供帮助的人。
#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;
}