rohit35

app

Mar 31st, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.48 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<conio.h>
  4. #include<string.h>
  5. #include<time.h>
  6. #define space "\t \t \t"
  7. typedef struct File2
  8. {
  9. void *portfolio;
  10. void *watchlist;
  11. void *account;
  12. void *transaction_histroy;
  13. } user_t;
  14. void userpage(char *users);
  15. void userpage(char *users)
  16. {
  17. int max=5,select=1,loop=1;
  18. user_sec:
  19. while(loop)
  20. {
  21. if(select >6||select ==0)
  22. {
  23. select =1;
  24. }
  25. system("cls");
  26. system("color 04");
  27. printf(" Stock Guide\n\n");
  28. if(select ==1)
  29. {
  30. printf("-> portfolio\n");
  31. }
  32. else
  33. {
  34. printf(" Portfolio\n");
  35. }
  36. if(select == 2)
  37. {
  38. printf("-> watchlist\n");
  39. }
  40. else
  41. {
  42. printf(" watchlist\n");
  43. }
  44. if(select==3)
  45. {
  46. printf("-> stock list\n");
  47. }
  48. else
  49. {
  50. printf(" stock list\n");
  51. }
  52. if(select==4)
  53. {
  54. printf("-> account\n");
  55. }
  56. else
  57. {
  58. printf(" account\n");
  59. }
  60. if(select ==5)
  61. {
  62. printf("-> Transaction Histroy\n");
  63. }
  64. else
  65. {
  66. printf(" Transaction histroy\n");
  67. }
  68. if(select==6)
  69. {
  70. printf("-> EXIT\n");
  71. }
  72. else
  73. {
  74. printf(" EXIT\n");
  75. }
  76. printf("Use the Arrow key's to move and select\n");
  77. switch(_getch())
  78. {
  79. case 'H':
  80. select--;
  81. // goto user_sec;
  82. break;
  83. case 'P':
  84. select++;
  85. // goto user_sec;
  86. break;
  87. case 13:
  88. if(select!=6)
  89. {
  90. user_choice(select,users);;
  91. }
  92. else
  93. {
  94. loop=0;
  95. }
  96. break;
  97. }
  98.  
  99. }
  100. }
  101. void user_choice(int choice,char *Name)
  102. {
  103. if(choice==1)
  104. portfolio(Name);
  105. else if(choice==2)
  106. watch_list(Name);
  107. else if(choice==3)
  108. stock_list(Name);
  109. else if(choice==4)
  110. my_Account(Name);
  111. else if(choice==5)
  112. trans_sec(Name);
  113. }
  114. void trans_sec(char* Name)
  115. {
  116.  
  117. }
  118. void watch_list(char* Name)
  119. {
  120.  
  121. }
  122. void stock_list(char *Name)
  123. {
  124.  
  125. }
  126. void my_Account(char *Name)
  127. {
  128. printf("My Account\n\n");
  129. printf("Name :%s\n",Name);
  130. printf("Starting Investment:50,000\n");
  131. // printf("Stock Value :%d",);
  132.  
  133. }
  134. void portfolio(char *Name)
  135. {
  136.  
  137. }
  138. int main()
  139. {
  140. system("color 04");
  141. printf("WELCOME\n");
  142. printf(" TO \n");
  143. printf(" HELIX \n");
  144. printf("Press any Key\n");
  145. _getch();
  146. Main_page();
  147. return 0;
  148. }
  149. int Main_page()
  150. {
  151. FILE *fp;
  152. char choice,x;
  153. char users[100];
  154. char username[100];
  155. char password[100];
  156. int i=0;
  157. main_sec:
  158. system("cls");
  159. while(1)
  160. {
  161. printf("Helix\n");
  162. printf("1)login\n");
  163. printf("2)signup\n");
  164. printf("3)exit");
  165. choice=_getch();
  166. if(choice== 49 || choice ==50 ||choice==51)
  167. break;
  168. else
  169. {
  170. printf("\nEnter valid choice\n");
  171. printf("press any key\n");
  172. _getch();
  173. system("cls");
  174. }
  175. }
  176. if(choice==49)
  177. {
  178. char x,*tempstr;
  179. char accountsDB[100];
  180. system("cls");
  181. printf("Login \n");
  182. printf("Username:");
  183. scanf("%s",username);
  184. printf("\n");
  185. i=0;
  186. while(username[i] != '\0')
  187. {
  188. users[i] = username[i];
  189. i++;
  190. }
  191. users[i] = '\0';
  192. i=0;
  193. printf("Password:");
  194. while ((x = _getch()) != '\r')
  195. {
  196. printf("*");
  197. password[i++] = x;
  198. }
  199. password[i] = '\0';
  200. i = 0;
  201. strcat(username, password);
  202. fp = fopen("PROJECT_DATA_FILE.txt","r");
  203. while((x = fgetc(fp)) != EOF)
  204. {
  205. accountsDB[i++] = x;
  206. }
  207. accountsDB[i] = '\0';
  208. fclose(fp);
  209. if(NULL == strstr(accountsDB, username))
  210. {
  211. printf("\n\n"space space"*Username or password is wrong");
  212. _getch();
  213. goto main_sec;
  214. }
  215. else
  216. {
  217. tempstr = strstr(accountsDB, username);
  218. }
  219. i=0;
  220. while(username[i]!='\0')
  221. {
  222. if(username[i]!=tempstr[i])
  223. break;
  224.  
  225. i++;
  226. }
  227. if(i==strlen(username))
  228. {
  229. userpage(users);
  230. goto main_sec;
  231. }
  232. else
  233. {
  234. printf("\n\n*Username or password is wrong");
  235. _getch();
  236. goto main_sec;
  237. }
  238. }
  239. if(choice ==50)
  240. {
  241. system("cls");
  242. printf("Signup\n");
  243. printf("Username:");
  244. scanf("%s",username);
  245. i=0;
  246. while((x = username[i]) != '\0')
  247. {
  248. if(x == '|' || x == '#' || x == '$')
  249. {
  250. printf("\n*Username must not contain special characters like |, #, $ etc.");
  251. _getch();
  252. goto main_sec;
  253. }
  254. i++;
  255. }
  256. char accountsDB[100];
  257. fp = fopen("PROJECT_DATA_FILE.txt","r");
  258. i = 0;
  259. while((x = fgetc(fp)) != EOF)
  260. {
  261. accountsDB[i++] = x;
  262. }
  263. fclose(fp);
  264. char temp_pass[100];
  265. if(NULL == strstr(accountsDB, username))
  266. {
  267. i=0;
  268. printf("Password:");
  269. while ((x = _getch()) != '\r')
  270. {
  271. printf("*");
  272. password[i++] = x;
  273. }
  274. password[i] = '\0';
  275. printf("\nRe-Enter password:");
  276. i = 0;
  277. while((x = _getch()) != '\r')
  278. {
  279. printf("*");
  280. temp_pass[i++] = x;
  281. }
  282. temp_pass[i]='\0';
  283. if(strcmp(temp_pass,password)==0)
  284. {
  285. i = 0;
  286. fp = fopen("PROJECT_DATA_FILE.txt","a");
  287. fputc('|',fp);
  288. while((x = username[i]) != '\0')
  289. {
  290. fputc(x,fp);
  291. i++;
  292. }
  293. i = 0;
  294. while((x = password[i]) != '\0')
  295. {
  296. fputc(x,fp);
  297. i++;
  298. }
  299. fputc('$', fp);
  300. fputc('1', fp);
  301. fputc('#', fp);
  302. fputc('1', fp);
  303. fclose(fp);
  304. printf("\n\nSign up successful");
  305. _getch();
  306. goto main_sec;
  307. }
  308. else
  309. {
  310. printf("\n\n*Passwords do not match, try again");
  311. _getch();
  312. goto main_sec;
  313. }
  314. }
  315. else
  316. {
  317. printf("\n*Username is already taken");
  318. _getch();
  319. goto main_sec;
  320. }
  321. }
  322. if(choice==51)
  323. {
  324. system("cls");
  325. printf("Exit\n\n");
  326. printf("Are You Sure Want to Exit\n");
  327. printf("Enter y/n\n");
  328. x=_getch();
  329. if(x=='n'||x=='N')
  330. goto main_sec;
  331. else
  332. {
  333. printf("Thank u for visiting\n");
  334. }
  335. }
  336. }
Add Comment
Please, Sign In to add comment