Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<conio.h>
- #include<string.h>
- #define space "\t \t \t"
- typedef struct File2
- {
- void *portfolio;
- void *watchlist;
- void *account;
- void *transaction histroy;
- } user_t;
- void userpage(char *users);
- void userpage(char *users)
- {
- int max=5,select=1;
- while(1)
- {
- system("cls");
- system("color 07");
- }
- }
- int main()
- {
- system("color 04");
- printf("WELCOME\n");
- printf(" TO \n");
- printf(" HELIX \n");
- printf("Press any Key\n");
- _getch();
- char users[100];
- if(Main_page(users)==0)
- {
- userpage(users);
- }
- else
- {
- printf("\nThank you for visiting\n");
- }
- return 0;
- }
- int Main_page(char *users)
- {
- FILE *fp;
- char choice,x;
- char username[100];
- char password[100];
- int i=0;
- main_sec:
- system("cls");
- while(1)
- {
- printf("Helix\n");
- printf("1)login\n");
- printf("2)signup\n");
- printf("3)exit");
- choice=_getch();
- if(choice== 49 || choice ==50 ||choice==51)
- break;
- else
- {
- printf("Enter valid choice\n");
- }
- }
- if(choice==49)
- {
- char x,*tempstr;
- char accountsDB[100];
- system("cls");
- printf("Login \n");
- printf("Username:");
- scanf("%s",username);
- printf("\n");
- i=0;
- while(username[i] != '\0')
- {
- users[i] = username[i];
- i++;
- }
- users[i] = '\0';
- i=0;
- printf("Password:");
- while ((x = _getch()) != '\r')
- {
- printf("*");
- password[i++] = x;
- }
- password[i] = '\0';
- i = 0;
- strcat(username, password);
- fp = fopen("PROJECT_DATA_FILE.txt","r");
- while((x = fgetc(fp)) != EOF)
- {
- accountsDB[i++] = x;
- }
- accountsDB[i] = '\0';
- fclose(fp);
- if(NULL == strstr(accountsDB, username))
- {
- printf("\n\n"space space"*Username or password is wrong");
- _getch();
- goto main_sec;
- }
- else
- {
- tempstr = strstr(accountsDB, username);
- }
- i=0;
- while(username[i]!='\0')
- {
- if(username[i]!=tempstr[i])
- break;
- i++;
- }
- if(i==strlen(username))
- {
- return 0;
- }
- else
- {
- printf("\n\n*Username or password is wrong");
- _getch();
- goto main_sec;
- }
- }
- if(choice ==50)
- {
- system("cls");
- printf("Signup\n");
- printf("Username:");
- scanf("%s",username);
- i=0;
- while((x = username[i]) != '\0')
- {
- if(x == '|' || x == '#' || x == '$')
- {
- printf("\n*Username must not contain special characters like |, #, $ etc.");
- _getch();
- goto main_sec;
- }
- i++;
- }
- char accountsDB[100];
- fp = fopen("PROJECT_DATA_FILE.txt","r");
- i = 0;
- while((x = fgetc(fp)) != EOF)
- {
- accountsDB[i++] = x;
- }
- fclose(fp);
- char temp_pass[100];
- if(NULL == strstr(accountsDB, username))
- {
- i=0;
- printf("Password:");
- while ((x = _getch()) != '\r')
- {
- printf("*");
- password[i++] = x;
- }
- password[i] = '\0';
- printf("\nRe-Enter password:");
- i = 0;
- while((x = _getch()) != '\r')
- {
- printf("*");
- temp_pass[i++] = x;
- }
- temp_pass[i]='\0';
- if(strcmp(temp_pass,password)==0)
- {
- i = 0;
- fp = fopen("PROJECT_DATA_FILE.txt","a");
- fputc('|',fp);
- while((x = username[i]) != '\0')
- {
- fputc(x,fp);
- i++;
- }
- i = 0;
- while((x = password[i]) != '\0')
- {
- fputc(x,fp);
- i++;
- }
- fputc('$', fp);
- fputc('1', fp);
- fputc('#', fp);
- fputc('1', fp);
- fclose(fp);
- printf("\n\nSign up successful");
- _getch();
- goto main_sec;
- }
- else
- {
- printf("\n\n*Passwords do not match, try again");
- _getch();
- goto main_sec;
- }
- }
- else
- {
- printf("\n*Username is already taken");
- _getch();
- goto main_sec;
- }
- }
- if(choice==51)
- {
- fclose(fp);
- return 1;
- }
- }
Add Comment
Please, Sign In to add comment