Hello Everybody.
The purpose for my code is to print some random code to a file but it's not.
Here's the code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
int main()
{
int keyUPPER=0, keyLOWER=0, keyINT=0, i=0, j=0;
char access[78];
char code1[10], code2[11];
FILE *read, *exec;
exec = fopen("key.txt", "w");
printf("Your access code for today is: ");
srand((int)time(0));
for (i=0; i<26; i++){
keyUPPER = ((rand()%25) + 65);
access[i] = keyUPPER;
}
for (i=i; i<52; i++){
keyINT = (rand()%8) + 49;
access[i] = keyINT;
}
for (i=i; i<78; i++){
keyLOWER = ((rand()%25) + 97);
access[i] = keyLOWER;
}
for (i=0; i<10; i++){
j = rand()%78;
printf("%c", access[j]);
fprintf(exec, "%c", access[j]);
}
printf("\n");
return 0;
}
Thanks in advance.