1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include <stdio.h>
#include <stdlib.h>
int connect_user();
int connect_user() {
char *tok = NULL;
long i = 0;
int choice;
char user[] = "";
char pass[] = "";
char currentdb[] = "a";
int actchar = 0;
FILE* db = NULL;
db = fopen("test.txt","r");
if(db != NULL) {
fscanf(db,"%s",¤tdb);
printf("%s",currentdb);
tok = strtok(currentdb,"|");
printf("Nom du Client | Adresse\n");
while(tok != NULL ) {
printf( "%s+++",tok );
tok = strtok( NULL, "|" ); }
system("PAUSE");
}
else {
printf("Cannot find data file.\n");
system("PAUSE");
}
}
int main(int argc, char *argv[])
{
int choice;
char user[] = "";
char pass[] = "";
char currentdb[] = "a";
int actchar = 0;
FILE* db = NULL;
db = fopen("test.txt","r");
printf("====Menu====\n");
printf("1-Connect\n");
printf("2-Close\n\n");
printf("Please choose your option... ");
scanf("%ld",&choice);
if(choice == 1) {
printf("\n\nUsername: ");
scanf("%s",&user);
if(strcmp(user,"Sacha") == 0) {
printf("\nUser %s OK. Password required.\n",user);
printf("Password: ");
scanf("%s",&pass);
if(strcmp(pass,"monpass") == 0) {
printf("\nConnection successful.\n");
connect_user();
}
else {
printf("\nInvalid password.\n");
system("PAUSE");
}
}
else {
printf("\nInvalid user.\n",user);
system("PAUSE");
}
} else if(choice == 2){
system("PAUSE");
}
else {
}
} |