rohit35

Twitter file(main)

Mar 16th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. #include<stdio.h>
  2. #include"linked_list.h"
  3. #include"users.h"
  4. #include "tweet.h"
  5. int main()
  6. {
  7. int choice;
  8. list_t *users = create_list();
  9. users->size=0;
  10. while(1)
  11. {
  12. fflush(stdout);
  13. system("color 04");
  14. printf("\n");
  15. printf("\t \t \tWELCOME TO TWEETER\n\n");
  16. printf("\t \t \t <<<MENU>>>\n");
  17. printf("\t \t \tpress 1 for signup\n");
  18. printf("\t \t \tpress 2 for login\n");
  19. printf("\t \t \tpress 3 for help\n");
  20. printf("\t \t \tpress 4 for exit\n");
  21. printf("\t \t \tenter your choice\n\t \t \t");
  22. scanf("%d",&choice);
  23. switch(choice)
  24. {
  25. case 1:
  26. signup(users);
  27. break;
  28. case 2:
  29. login(users);
  30. system("cls");
  31. break;
  32. case 3:
  33. help(users);
  34. break;
  35. case 4:
  36. printf("\t \t \tThank You For Visiting\n");
  37. exit(NULL);
  38. case 5:users_print(users);
  39. break;
  40. default:
  41. status();
  42. break;
  43. }
  44. }
  45. pritnf("\t \t \tThank you for visiting\n");
  46. return 0;
  47. }
  48. void status()
  49. {
  50. printf("\t \t \tplease enter valid choice\n");
  51. }
  52. void signup(list_t *users)
  53. {
  54. system("cls");
  55. printf("\n");
  56. printf("\t \t \t<<<Welcome to signup>>>\n");
  57. char *name =(char*)malloc(512*sizeof(char));
  58. char *password = (char*)malloc(512*sizeof(char));
  59. printf("\n");
  60. printf("\t \t \tEnter the name\n\t \t \t");
  61. fflush(stdin);
  62. gets(name);
  63. fflush(stdin);
  64. printf("\t \t \tenter the password\n\t \t \t");
  65. gets(password);
  66. if(!user_create(users,name,password))
  67. {
  68. printf("\t \t \tFailed\n");
  69. }
  70. else
  71. {
  72. printf("\t \t \tYou have succesfully singup\n");;
  73. }
  74. clear();
  75. free(password);
  76. free(name);
  77. system("cls");
  78. }
  79. void login(list_t *users)
  80. {
  81. system("cls");
  82. printf("\n");
  83. printf("\t \t \t<<<welcome to login>>>\n\n");
  84. char name[512];
  85. char password[512];
  86. printf("\t \t \tEnter the name\n\t \t \t");
  87. fflush(stdin);
  88. gets(name);
  89. fflush(stdin);
  90. printf("\t \t \tenter the password\n\t \t \t");
  91. gets(password);
  92. if(strlen(name) !=0 && strlen(password)!=0)
  93. {user_search(users,name,password);}
  94. else
  95. {
  96. printf("\t \t \tFill the required details\n");
  97. }
  98. clear();
  99. }
  100. void help(list_t *users)
  101. {
  102. system("cls");
  103. int choice,key=1;
  104. while(key!=3)
  105. {
  106. printf("\n");
  107. printf("\t \t \t<<Help Section>>>\n\n");
  108. printf("\t \t \tPress 1 for forgot password\n");
  109. printf("\t \t \tPress 2 for Back\n");
  110. printf("\t \t \tEnter your choice\n");
  111. printf("\t \t \t");
  112. fflush(stdin);
  113. scanf("%d",&choice);
  114. switch(choice)
  115. {
  116. case 1:
  117. forgot_password(users);
  118. break;
  119. case 2:
  120. key=3;
  121. break;
  122. default:
  123. status();
  124. break;
  125. }
  126. system("cls");
  127. }
  128. }
  129. void forgot_password(list_t *users)
  130. {
  131. if (users->head == NULL)
  132. {
  133. printf("\t \t \tThe list is Empty\n");
  134. }
  135. else
  136. {
  137. system("cls");
  138. char name[512],id[512];
  139. printf("\t \t \t<<<Forgot Password>>>\n\n");
  140. printf("\t \t \tEnter your username\n");
  141. printf("\t \t \t");
  142. fflush(stdin);
  143. gets(name);
  144. printf("\t \t \tEnter your id Number\n");
  145. printf("\t \t \t");
  146. fflush(stdin);
  147. gets(id);
  148. node_t *li = NULL;
  149. user_t *user = NULL;
  150. int flag=0;
  151. printf("\n");
  152. printf("\t \t \tYour Account Details \n");
  153. printf("\t \t \tId : username : password\n");
  154. for (li = users->head ; li != NULL ; li = li->next)
  155. {
  156. user = (user_t *)li->data;
  157. if(compare_name(li,name) && compare_id(li,id))
  158. {
  159. flag++;
  160. printf("\t \t \t%s : %s : %s\n",((char*) user->id),((char*) user->name),((char*)user->password));
  161. break;
  162. }
  163. }
  164. if(flag==0)
  165. {
  166. printf("\t \t \tNULL : NULL : NULL\n");
  167. }
  168. }
  169. clear();
  170. }
  171. void clear()
  172. {
  173. char any;
  174. printf("\t \t \tPress any Key\n");
  175. printf("\t \t \t");
  176. fflush(stdin);
  177. scanf("%c",&any);
  178. }
Add Comment
Please, Sign In to add comment