Notification texts go here Contact Us Click here

Contact Management System Project Using C Language .

Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

  1. #include<stdio.h>
  2.  
  3. #include<conio.h>
  4.  
  5. #include<string.h>
  6.  
  7. #include<process.h>
  8.  
  9. #include<stdlib.h>
  10.  
  11. #include<dos.h>
  12.  
  13. struct contact
  14.  
  15. {
  16.  
  17. long ph;
  18.  
  19. char name[20],add[20],email[30];
  20.  
  21. } list;
  22.  
  23. char query[20],name[20];
  24.  
  25. FILE *fp, *ft;
  26.  
  27. int i,n,ch,l,found;
  28.  
  29. int main()
  30.  
  31. {
  32.  
  33. main:
  34.  
  35. system("cls"); /* ************Main menu *********************** */
  36.  
  37.  
  38. printf("\n\n\n\t\t\tMAIN MENU\n\t\t=====================\n\t\t[1] Add a new Contact\n\t\t[2] List all Contacts\n\t\t[3] Search for contact\n\t\t[4] Edit a Contact\n\t\t[5] Delete a Contact\n\t\t[0] Exit\n\t\t=================\n\t\t");
  39.  
  40. printf("Enter the choice:");
  41.  
  42. scanf("%d",&ch);
  43.  
  44. switch(ch)
  45.  
  46. {
  47.  
  48. case 0:
  49.  
  50. printf("\n\n\t\t Are you sure you want to exit?");
  51.  
  52. break;
  53.  
  54. /* *********************Add new contacts************ */
  55.  
  56. case 1:
  57.  
  58. system("cls");
  59.  
  60. fp=fopen("contact.dll","a");
  61.  
  62. for (;;)
  63.  
  64. {
  65. fflush(stdin);
  66.  
  67. printf("To exit enter blank space in the name input\nName (Use identical):");
  68.  
  69. scanf("%[^\n]",&list.name);
  70.  
  71. if(stricmp(list.name,"")==0 || stricmp(list.name," ")==0)
  72.  
  73. break;
  74.  
  75. fflush(stdin);
  76.  
  77. printf("Phone:");
  78.  
  79. scanf("%ld",&list.ph);
  80.  
  81. fflush(stdin);
  82.  
  83. printf("address:");
  84.  
  85. scanf("%[^\n]",&list.add);
  86.  
  87. fflush(stdin);
  88.  
  89. printf("email address:");
  90.  
  91. gets(list.email);
  92.  
  93. printf("\n");
  94.  
  95. fwrite(&list,sizeof(list),1,fp);
  96.  
  97. }
  98.  
  99. fclose(fp);
  100.  
  101. break;
  102.  
  103. /* *********************list of contacts************************* */
  104.  
  105. case 2:
  106.  
  107. system("cls");
  108.  
  109. printf("\n\t\t================================\n\t\t\tLIST OF CONTACTS\n\t\t================================\n\nName\t\tPhone No\t Address\t\tE-mail ad.\n=================================================================\n\n");
  110.  
  111. for(i=97; i<=122; i=i+1)
  112.  
  113. {
  114.  
  115. fp=fopen("contact.dll","r");
  116.  
  117. fflush(stdin);
  118.  
  119. found=0;
  120.  
  121. while(fread(&list,sizeof(list),1,fp)==1)
  122.  
  123. {
  124.  
  125. if(list.name[0]==i || list.name[0]==i-32)
  126.  
  127. {
  128.  
  129. printf("\nName\t: %s\nPhone\t: %ld\nAddress\t: %s\nEmail\t: %s\n",list.name,
  130.  
  131. list.ph,list.add,list.email);
  132.  
  133. found++;
  134.  
  135. }
  136.  
  137. }
  138.  
  139. if(found!=0)
  140.  
  141. {
  142. printf("=========================================================== [%c]-(%d)\n\n",i-32,found);
  143.  
  144. getch();
  145. }
  146.  
  147. fclose(fp);
  148.  
  149. }
  150.  
  151. break;
  152.  
  153. /* *******************search contacts********************** */
  154.  
  155. case 3:
  156.  
  157. system("cls");
  158.  
  159. do
  160.  
  161. {
  162.  
  163. found=0;
  164.  
  165. printf("\n\n\t..::CONTACT SEARCH\n\t===========================\n\t..::Name of contact to search: ");
  166.  
  167. fflush(stdin);
  168.  
  169. scanf("%[^\n]",&query);
  170.  
  171. l=strlen(query);
  172.  
  173. fp=fopen("contact.dll","r");
  174.  
  175. system("cls");
  176.  
  177. printf("\n\n..::Search result for '%s' \n===================================================\n",query);
  178.  
  179. while(fread(&list,sizeof(list),1,fp)==1)
  180.  
  181. {
  182.  
  183. for(i=0; i<=l; i++)
  184.  
  185. name[i]=list.name[i];
  186.  
  187. name[l]='\0';
  188.  
  189. if(stricmp(name,query)==0)
  190.  
  191. {
  192.  
  193. printf("\n..::Name\t: %s\n..::Phone\t: %ld\n..::Address\t: %s\n..::Email\t: %s\n",list.name,list.ph,list.add,list.email);
  194.  
  195. found++;
  196.  
  197. if (found%4==0)
  198.  
  199. {
  200.  
  201. printf("..::Press any key to continue...");
  202.  
  203. getch();
  204.  
  205. }
  206.  
  207. }
  208.  
  209. }
  210.  
  211. if(found==0)
  212.  
  213. printf("\n..::No match found!");
  214.  
  215. else
  216.  
  217. printf("\n..::%d match(s) found!",found);
  218.  
  219. fclose(fp);
  220.  
  221. printf("\n ..::Try again?\n\n\t[1] Yes\t\t[0] No\n\t");
  222.  
  223. scanf("%d",&ch);
  224.  
  225. }
  226. while(ch==1);
  227.  
  228. break;
  229.  
  230. /* *********************edit contacts************************/
  231.  
  232. case 4:
  233.  
  234. system("cls");
  235.  
  236. fp=fopen("contact.dll","r");
  237.  
  238. ft=fopen("temp.dat","w");
  239.  
  240. fflush(stdin);
  241.  
  242. printf("..::Edit contact\n===============================\n\n\t..::Enter the name of contact to edit:");
  243.  
  244. scanf("%[^\n]",name);
  245.  
  246. while(fread(&list,sizeof(list),1,fp)==1)
  247.  
  248. {
  249.  
  250. if(stricmp(name,list.name)!=0)
  251.  
  252. fwrite(&list,sizeof(list),1,ft);
  253.  
  254. }
  255.  
  256. fflush(stdin);
  257.  
  258. printf("\n\n..::Editing '%s'\n\n",name);
  259.  
  260. printf("..::Name(Use identical):");
  261.  
  262. scanf("%[^\n]",&list.name);
  263.  
  264. fflush(stdin);
  265.  
  266. printf("..::Phone:");
  267.  
  268. scanf("%ld",&list.ph);
  269.  
  270. fflush(stdin);
  271.  
  272. printf("..::address:");
  273.  
  274. scanf("%[^\n]",&list.add);
  275.  
  276. fflush(stdin);
  277.  
  278. printf("..::email address:");
  279.  
  280. gets(list.email);
  281.  
  282. printf("\n");
  283.  
  284. fwrite(&list,sizeof(list),1,ft);
  285.  
  286. fclose(fp);
  287.  
  288. fclose(ft);
  289.  
  290. remove("contact.dll");
  291.  
  292. rename("temp.dat","contact.dll");
  293.  
  294. break;
  295.  
  296. /* ********************delete contacts**********************/
  297.  
  298. case 5:
  299.  
  300. system("cls");
  301.  
  302. fflush(stdin);
  303.  
  304. printf("\n\n\t..::DELETE A CONTACT\n\t==========================\n\t..::Enter the name of contact to delete:");
  305.  
  306. scanf("%[^\n]",&name);
  307.  
  308. fp=fopen("contact.dll","r");
  309.  
  310. ft=fopen("temp.dat","w");
  311.  
  312. while(fread(&list,sizeof(list),1,fp)!=0)
  313.  
  314. if (stricmp(name,list.name)!=0)
  315.  
  316. fwrite(&list,sizeof(list),1,ft);
  317.  
  318. fclose(fp);
  319.  
  320. fclose(ft);
  321.  
  322. remove("contact.dll");
  323.  
  324. rename("temp.dat","contact.dll");
  325.  
  326. break;
  327.  
  328. default:
  329.  
  330. printf("Invalid choice");
  331.  
  332. break;
  333.  
  334. }
  335.  
  336. printf("\n\n\n..::Enter the Choice:\n\n\t[1] Main Menu\t\t[0] Exit\n");
  337.  
  338. scanf("%d",&ch);
  339.  
  340. switch (ch)
  341.  
  342. {
  343.  
  344. case 1:
  345.  
  346. goto main;
  347.  
  348. case 0:
  349.  
  350. break;
  351.  
  352. default:
  353.  
  354. printf("Invalid choice");
  355.  
  356. break;
  357.  
  358. }
  359.  
  360. return 0;
  361.  
  362. }
Explanation In C, here's everything you need to know about the Contact Management System: The primary components of this basic C mini project are file management, data structure, functions, and pointers. The following are the essential elements of a contact management system: Add new contacts, including their name, phone number, address, and email address. List all contacts: displays a list of all the contacts in the file, along with their contact information. Contacts may be found by searching by name and phone number. Edit contacts: Make changes to the information provided when adding contacts, such as name, phone number, address, and email address. Delete contacts: removes contacts from the database. This project is identical to the Phonebook application mini-project that we previously shared. File management and data structures are used in both of these little projects. They're designed as a basic console application for novices to study and create small projects

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.