I wrote this program by the lunch time, compiled at:
http://www.delorie.com/djgpp/compile/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct{
char usr[20];
char pwd[20];
int num;
}USR;
int main(int argc, char **argv){
USR new;
FILE * log;
srand(time(NULL));
printf("n\n\n\t\tEnter Username: ");
gets(new.usr);
system("cls");
printf("n\n\n\t\tEnter Password: ");
gets(new.pwd);
new.num = 1 + rand() % 999;
if((log = fopen("user.by","w+"))){
printf("Standard Storage File Failure\a\n");
exit(EXIT_SUCCESS);
}else{
printf("Processing.....");
system("dir");
if((fprintf(log,"%d\t%s\t%s\n",new.num,new.usr,new .pwd))){
printf("new user *%s* created...\n",new.usr);
}else{
printf("Unable to create user...\n");
}
}
fclose(log);
return 0;
}
the file created by the program is called "user.by" when opened there is nothing on it. i will try to use fflush and create an app to read this file.