C language to do an address book program (run inside the console)

Source: Internet
Author: User

Recently reviewed the C language when I saw the internet has a C language Address Book Small project, so I looked at the next program to achieve the approximate function, and then I also followed a. The code is simple enough to be affixed to someone in need.

1 //2 //main.m3 //Adressbook4 //5 //Created by Bestkayle on 15/8/8.6 //Copyright (c) 2015 Bestkayle. All rights reserved.7 //8 9#import <Foundation/Foundation.h>Ten intAmount =1;//Contact Number One intNum//the input instruction A intXuhao;//Contact Number -typedefstructContact { -     Charname[ -]; the     intTelenumber; - }co; -Co person[ -] = { -{"Kayle",12345678}, + }; - voidaddcontracts () { + //for (int i = 0; i <; i + +) { A //For (int j = i; J < amount; J + +) { at //person[j+1] = person[j]; - //        } - //    } - } - voiddeletecontracts (Xuhao) { -      for(inti = xuhao-1; I < amount; i++) { inPerson[i] = person[i+1]; -     } to } + voidfixcontracts (Xuhao) { -      the } * voidDisplayall () { $      for(inti =0; I < amount; i + +) {Panax Notoginsengprintf"%d.%s%d\n", i+1, person[i].name,person[i].telenumber); -     } the } + voidSearchone (Xuhao) { Aprintf"%d.%s%d\n", xuhao,person[xuhao-1].name,person[xuhao-1].telenumber); the } + intMainintargcConst Char*argv[]) { -printf"**********************************\n"); $printf"****** Welcome to the address Book ************\n"); $printf"****** 1. Add a contact ************\n"); -printf"****** 2. Delete a contact ************\n"); -printf"****** 3. Modify the contact person ************\n"); theprintf"****** 4. View all contacts ************\n"); -printf"****** 5. Search Contact *************\n");Wuyiprintf"****** 6. Exit Address Book *************\n"); theprintf"***********************************\n"); -printf"Please follow the instructions: \ n"); Wu      while(num! =6){ -scanf"%d",&num); About     Switch(num) { $          Case 1: -Amount + +; -           //addcontracts (); -printf"Please enter your name and phone number:"); A             Charname[ -] = {0}; +             intTelenumber; thescanf"%s%d",&*name,&telenumber); -strcpy (person[amount-1].name,name); $person[amount-1].telenumber =Telenumber; theprintf"has been deposited \ n"); the              Break; the          Case 2: theAmount--; -printf"Please enter the serial number:"); inscanf"%d",&Xuhao); the deletecontracts (Xuhao); the              Break; About          Case 3: theprintf"Please enter the serial number:"); thescanf"%d",&Xuhao); theprintf"to modify a contact Please enter 1, please enter the phone number 2:"); +             intChoose; -scanf"%d",&choose); the             if(Choose = =1) {Bayi                 Charname[ -] = {0}; theprintf"Please enter your name"); thescanf"%s", name); -strcpy (person[xuhao-1].name, name); -             } the             Else{ the                 intTelenumber; theprintf"Please enter your phone number"); thescanf"%d",&telenumber); -person[xuhao-1].telenumber =Telenumber; the             } the              Break; the          Case 4:94 Displayall (); the              Break; the          Case 5: theprintf"Please enter the serial number:");98scanf"%d",&Xuhao); About Searchone (Xuhao); -         default:101          Break;}102         if(num = =6) {103printf"exiting ... \ n");104Sleep1); theprintf"has exited!");106         }107             108     }109}

C language to do an address book program (run inside the console)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.