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>
- #include<time.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,loop=1;
- user_sec:
- while(loop)
- {
- if(select >6||select ==0)
- {
- select =1;
- }
- system("cls");
- system("color 04");
- printf(" Stock Guide\n\n");
- if(select ==1)
- {
- printf("-> portfolio\n");
- }
- else
- {
- printf(" Portfolio\n");
- }
- if(select == 2)
- {
- printf("-> watchlist\n");
- }
- else
- {
- printf(" watchlist\n");
- }
- if(select==3)
- {
- printf("-> stock list\n");
- }
- else
- {
- printf(" stock list\n");
- }
- if(select==4)
- {
- printf("-> account\n");
- }
- else
- {
- printf(" account\n");
- }
- if(select ==5)
- {
- printf("-> Transaction Histroy\n");
- }
- else
- {
- printf(" Transaction histroy\n");
- }
- if(select==6)
- {
- printf("-> EXIT\n");
- }
- else
- {
- printf(" EXIT\n");
- }
- printf("Use the Arrow key's to move and select\n");
- switch(_getch())
- {
- case 'H':
- select--;
- // goto user_sec;
- break;
- case 'P':
- select++;
- // goto user_sec;
- break;
- case 13:
- if(select!=6)
- {
- user_choice(select,users);;
- }
- else
- {
- loop=0;
- }
- break;
- }
- }
- }
- void user_choice(int choice,char *Name)
- {
- if(choice==1)
- portfolio(Name);
- else if(choice==2)
- watch_list(Name);
- else if(choice==3)
- stock_list(Name);
- else if(choice==4)
- my_Account(Name);
- else if(choice==5)
- trans_sec(Name);
- }
- void trans_sec(char* Name)
- {
- }
- void watch_list(char* Name)
- {
- }
- void stock_list(char *Name)
- {
- }
- void my_Account(char *Name)
- {
- printf("My Account\n\n");
- printf("Name :%s\n",Name);
- printf("Starting Investment:50,000\n");
- // printf("Stock Value :%d",);
- }
- void portfolio(char *Name)
- {
- }
- int main()
- {
- system("color 04");
- printf("WELCOME\n");
- printf(" TO \n");
- printf(" HELIX \n");
- printf("Press any Key\n");
- _getch();
- Main_page();
- return 0;
- }
- int Main_page()
- {
- FILE *fp;
- char choice,x;
- char users[100];
- 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("\nEnter valid choice\n");
- printf("press any key\n");
- _getch();
- system("cls");
- }
- }
- 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))
- {
- userpage(users);
- goto main_sec;
- }
- 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)
- {
- system("cls");
- printf("Exit\n\n");
- printf("Are You Sure Want to Exit\n");
- printf("Enter y/n\n");
- x=_getch();
- if(x=='n'||x=='N')
- goto main_sec;
- else
- {
- printf("Thank u for visiting\n");
- }
- }
- }
Add Comment
Please, Sign In to add comment