Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.23 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<conio.h>
  4. #include<stdlib.h> //for using styme("CLS")
  5. #define ENTER 13
  6. #define BKSP 8
  7. //subfunction diclaration
  8. void login();
  9. void menu();
  10. struct data
  11. {
  12. int phone,batch;
  13. char name [100];
  14. char email[100];
  15. char blood_group[10];
  16.  
  17. } entry;
  18.  
  19. //char query[20],name[20];
  20. // FILE *fp,*ft;
  21. // int i,n,l,found;
  22. int main()
  23. {
  24.  
  25. login(); // call login function
  26. return 0;
  27. }
  28. void login()
  29. {
  30. int i;
  31. char password[100],ch;
  32. char username[100];
  33. printf("\n\n\t\t*************************************************\n\t\t*\t\t\t\t\t\t*\n\t\t*\tENTER YOUR USERNAME AND PASSWORD\t*\n\t\t*\t\t\t\t\t\t*\n\t\t*************************************************\n");
  34. printf("\n\t\t\tUSERNAME:");
  35. scanf("%s",&username);
  36. printf("\n\t\t\tPASSWORD:");
  37.  
  38. for(i=0; i<100; i++) //loop for password input
  39.  
  40. {
  41. ch = getch(); //getch don't showing input from user
  42. if(ch==ENTER)
  43. {
  44. break;
  45. }
  46.  
  47. else
  48. {
  49. password[i] = ch;
  50. ch = '*' ;
  51. printf("%c",ch);
  52. }
  53.  
  54. }
  55.  
  56. password[i] = '\0'; //in string last character is a null character
  57. if(strcmp(username,"abc")==0) // strcmp for compearision
  58. {
  59.  
  60.  
  61. if(strcmp(password,"123")==0)
  62. {
  63. getch(); // getch is used to hold the window
  64. system("CLS");
  65. printf("\n\n\t\tSUCCESSFULLY LOG IN......");
  66. printf("\n\n\t\tPress Any Key To Countinue..... ");
  67. getch();
  68. system("CLS");
  69. menu(); // call menu function
  70. }
  71. else
  72. {
  73. printf("\n\n\t\tPlease Enter Correct Password.....");
  74. printf("\n\n\t\tPress Any Key To Countinue..... ");
  75. getch();
  76. system("CLS"); //system("CLS") using for clear screen
  77. login(); // call login function
  78. }
  79.  
  80.  
  81. }
  82. else
  83. {
  84. printf("\n\n\t\tPlease Enter Correct Username.....");
  85. printf("\n\n\t\tPress Any Key To Countinue..... ");
  86. getch();
  87. system("CLS");
  88. login(); // call login function
  89. }
  90.  
  91.  
  92.  
  93.  
  94. }
  95.  
  96. void menu()
  97. {
  98. int choice,quit,c;
  99. FILE *fp,*ft;
  100. int i,n,l,found;
  101. printf("\n\n\t\t ======WELCOME TO BLOOD GROUP MANAGEMENT======\n");
  102. printf("\n\n\t\t\t*********************************\n\t\t\t*\t\t\t\t*\n\t\t\t*\t Main Menu \t*\n\t\t\t*\t\t\t\t*\n\t\t\t*********************************\n\t\t\t*\t\t\t\t*");
  103. printf("\n\t\t\t*\t [1]Data Entry\t\t*\n");
  104. printf("\t\t\t*\t [2]All List\t\t*\n");
  105. printf("\t\t\t*\t [3]Search\t\t*\n");
  106. printf("\t\t\t*\t [4]Delete\t\t*\n");
  107. printf("\t\t\t*\t [5]About Us\t\t*\n");
  108. printf("\t\t\t*\t [6]Exit\t\t*\n\t\t\t*\t\t\t\t*\n");
  109. printf("\t\t\t*********************************\n\n");
  110. printf("\t\t\t\tChoise Any Number: ");
  111.  
  112. scanf("%d",&choice);
  113.  
  114. switch(choice)
  115. {
  116.  
  117. case 6:
  118. system("CLS");
  119. printf("\n\n\n\t\t\t*********************************\n\t\t\t*\t Are you sure?\t*\n\t\t\t*********************************\n\t\t\t*\t[1]YES *\t[2]NO *\n\t\t\t*********************************");
  120. printf("\n\n\t\t\tChoise Any Number: ");
  121. scanf("%d",&quit);
  122. if(quit==1)
  123. {
  124. system("CLS");
  125. printf("\n\n\n\n\n\n\t\t\t*********Thanks For Using*********\n\n\n\n\n\n\n\n\n\n\n");
  126. break;
  127. }
  128. else if(quit==2)
  129. {
  130.  
  131. system("CLS");
  132. menu(); // call menu function
  133. }
  134. else
  135. {
  136. printf("\n\n\t\t\tInvalid....\n\n ");
  137. getch();
  138. system("CLS");
  139. menu(); //if invalid go to menu
  140.  
  141.  
  142. }
  143. break;
  144. case 2:
  145. system("CLS");
  146. printf("\n\n\t\t\tAll lists:\n\n");
  147. for(i=0;i<100;i++)
  148. {
  149. printf("\t\t\t%d.Empty\n",i);
  150. }
  151. printf("\n\n\t\t\tPress 1 to go back.");
  152. scanf("%d",&c);
  153. if(c==1)
  154. {
  155. system("CLS");
  156. menu();
  157. }
  158. case 1:
  159. system("CLS");
  160. fp=fopen("bloodgroup.txt","a"); //open a text file name bloodgroup.txt
  161. printf("\n\n\t\t\t ENTRY YOUR USEFUL DATA\n\t===========================================================");
  162.  
  163. while(1)
  164. {
  165. fflush(stdin); //fflush(stdin) using for clear buffer memory
  166. printf("\n\t\t(to exit enter a blank space in name option)");
  167. printf("\n\n\t\t\tName:");
  168. gets(entry.name);
  169. if( strcmp(entry.name," ")==0)
  170. {
  171. break;
  172. }
  173. fflush(stdin);
  174. printf("\t\t\tBlood Group:");
  175. gets(entry.blood_group);
  176. fflush(stdin);
  177. printf("\t\t\tBatch:");
  178. scanf("%d",&entry.batch);
  179. fflush(stdin);
  180. printf("\t\t\tPhone:");
  181. scanf("[%d",&entry.phone);
  182. fflush(stdin);
  183. printf("\t\t\tEmail:");
  184. gets(entry.email);
  185. fflush(stdin);
  186. fwrite(&entry,sizeof(entry),1,fp); //fwrite for written all entry in file
  187. system("CLS");
  188. printf("\n\n\t\t\t ENTRY YOUR USEFUL DATA\n\t===========================================================");
  189. }
  190. printf("\n\n\n\t\t\t(Press [1]exit or [2]menu)");
  191. printf("\n\n\t\t\tChoise Any Number: ");
  192. scanf("%d",&quit);
  193. if(quit==1)
  194. {
  195. system("CLS");
  196. printf("\n\n\n\n\n\n\t\t\t*********Thanks For Using*********\n\n\n\n\n\n\n\n\n\n\n");
  197. break;
  198. }
  199. else if(quit==2)
  200. {
  201.  
  202. system("CLS");
  203. menu(); // call menu function
  204. }
  205. else
  206. {
  207. printf("\n\n\t\t\tPlease Enter Valid Option....\n\n ");
  208. getch();
  209. system("CLS");
  210. menu();
  211.  
  212. fclose(fp); //closing file
  213. break;
  214. case 5:
  215. system("CLS");
  216. printf("\n\n\t\tINFORMATION ABOUT GROUP 404 NOT FOUND\n\t===========================================================");
  217. printf("\n\t\tName:Md.Mahedi Hasan\n\t\tID:181-15-10900\n\t\tSECTION:D\n");
  218. printf("\n\t\tName:Sajib Ahmed\n\t\tID:181-15-10874\n\t\tSECTION:D\n");
  219. printf("\n\t\tName:Mohd.Mehedi Hasan Joy\n\t\tID:181-15-10628\n\t\tSECTION:D\n");
  220. printf("\n\t\tName:Akkhar Ulok\n\t\tID:181-15-11207\n\t\tSECTION:D");
  221. printf("\n\n\t\t\tThis is an c project\n\t===========================================================");
  222. printf("\n\t\t\tPress any key to continue....");
  223. getch();
  224. system("CLS");
  225. menu();
  226. break;
  227.  
  228.  
  229.  
  230. default:
  231.  
  232. printf("\n\t\t\tPlease Enter Valid Option....");
  233. printf("\n\t\t\tPress any key to continue....");
  234. getch();
  235. system("CLS");
  236. menu();
  237. break;
  238. }
  239.  
  240.  
  241.  
  242. }
  243. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement