通讯录c语言程序代码,要菜单显示、c语言打开文件乱码、保存文件、全部显示、查找、删除、修改、添加、排序好友

"通讯录管理系统c语言源代码"的糗事
你可能感兴趣:
糗事百科为大家收集了很多的通讯录管理系统c语言源代码的糗事,各种关于通讯录管理系统c语言源代码的爆笑经历、尴尬时刻和开心视频,想持续关注通讯录管理系统c语言源代码的糗事就收藏本页吧.
扫码下载糗事百科app【黑马程序员】C语言—通讯录系统的实现
------、期待与您交流! -------
c语言通讯录系统实现:
需求分析:
利用文件读,写的方法
实现增加通讯录联系人信息
实现删除通讯录联系人信息
实现查找通讯录联系人信息
实现修改通讯录联系人信息
实现查看现有通讯录联系人信息
代码实现:
&span style="font-size:14"&//
C语言通讯录实现
Created by Brisinga on 15/10/14.
Copyright (C) 2015年 yan. All rights reserved.
#include &stdio.h&
#include&string.h&
#define LEN 10
#define NAMELEN 22
#define TELLEN 12
//*************结构体变量定义****************
//定义联系人的个数
int contactCount = 0;
//定义结构体
typedef struct{
//定义联系人姓名
char name[NAMELEN];
//定义联系人电话
char tel[TELLEN];
//初始化联系人数组
Person contact[LEN];
//定义文件名
char *path = "a.data";
//接收用户输入的编号
//**************函数声明********************
//初始化声明
void init();
//校验声明
int isValid(int n,int min,int max);
//添加联系人
void addContact();
//删除联系人
void deleteContact();
//修改联系人
void updateContact();
//查看所有联系人
void doList();
//搜索联系人
void searchContact();
//退出系统
void quit();
//联系人写入文件
void writeFile();
//***************************************
int main(int argc, const char * argv[]) {
//通讯录初始化
printf("通讯录初始化成功!\n");
while (1) {
//定义界面
printf("**********************************\n");
printf("***********欢迎使用通讯录***********\n");
printf("***********1.添加联系人*************\n");
printf("***********2.删除联系人*************\n");
printf("***********3.修改联系人*************\n");
printf("***********4.查看所有联系人**********\n");
printf("***********5.搜索联系人*************\n");
printf("***********6.退出系统***************\n");
printf("**********************************\n");
//提示用户输入编号
printf("请输入要进行操作的编号:\n");
scanf("%d",&no);
//判断输入是否合法
isValid(no, 1, 6);
//判断用户的操作
switch (no) {
//添加联系人
addContact();
//删除联系人
deleteContact();
//更新联系人
updateContact();
//查看联系人
//搜索联系人
searchContact();
//通讯录初始化
void init(){
//定义文件指针
FILE *fp = fopen(path, "r");
//判断通讯录是否存在
if (fp!=NULL) {
//如果存在
//1.读取联系人个数
fread(&contactCount, sizeof(contactCount), 1, fp);
//2.读取每一个联系人nts
for (int i=0; i&contactC i++) {
fread(&contact[i], sizeof(Person), 1, fp);
//如果不存在
//创建通讯录
fp = fopen(path, "wb");
//写入当前联系人的个数
fwrite(&contactCount, sizeof(contactCount), 1, fp);
fclose(fp);
//校验输入是否合法
int isValid(int n,int min,int max){
//如果输入的编号大于min小于max,则返回0
if (n&=min&&n&=max) {
//否则返回1
printf("输入非法!\n");
//添加联系人
void addContact(){
//提示用户输入要添加联系人的姓名
printf("请输入要添加的联系人姓名:*注意姓名之间不能有空格\n");
//接收联系人姓名
scanf("%s",contact[contactCount].name);
//提示用户输入要添加联系任的电话
printf("请输入要添加联系人的电话: *注意电话号码之间不能有空格\n");
//接收联系人电话
scanf("%s",contact[contactCount].tel);
//询问是否确定添加
printf("确定要添加么?1.确定
0.取消\n");
scanf("%d",&no);
contactCount++;
//写入文件
writeFile();
printf("添加成功!\n");
//删除联系人
void deleteContact(){
//显示联系人
//提示用户输入要删除联系人的编号
printf("请输入要删除联系人的编号:\n");
//接收用户输入的编号
scanf("%d",&no);
//判断编号是否合法
if(!isValid(no, 1, contactCount)){
//编号合法
printf("确定要删除么?删除后将无法恢复!1.确定 0.取消\n");
scanf("%d",&flag);
if (flag) {
//如果要删除的联系人在末尾
if (no==contactCount) {
//则contactCount-1
contactCount--;
//如果要删除的联系人不在末尾
//移动数组元素
for (int i=no-1; i&contactCount-1; i++) {
contact[i]=contact[i+1];
//contactCount--
contactCount--;
writeFile();
//编号不合法,则退出
printf("编号不合法!\n");
//修改联系人
void updateContact(){
//显示联系人
//提示用户输入要修改联系人的编号
printf("请输入要修改的联系人的编号:\n");
//接收用户输入的编号
scanf("%d",&no);
//判断编号是否合法
if (!isValid(no, 1, contactCount)) {
//提示用户输入新的的联系人的姓名
printf("请输入新的姓名:*注意:姓名之间不能有空格\n");
//接收用户输入的姓名
scanf("%s",contact[no-1].name);
//提示用户输入新的电话号码
printf("请输入新的电话号码:*注意:电话号码之间不能有空格\n");
//接收用户输入的电话号码
scanf("%s",contact[no-1].tel);
//询问用户确定修改么?
printf("确定要修改么?1.确定 0.取消\n");
scanf("%d",&flag);
if (flag) {
writeFile();
printf("联系人修改成功!\n");
printf("编号不合法!!\n");
//查看所有联系人
void doList(){
printf("显示所有联系人:\n");
printf("编号\t姓名\t电话\n");
for (int i=0; i&contactC i++) {
printf("%d\t%s\t%s\n",i+1,contact[i].name,contact[i].tel);
//搜索联系人
void searchContact(){
int flag = 1;
//接收用户输入的姓名
char searchName[NAMELEN];
//接收用户输入的电话
char searchTel[TELLEN];
//询问用户搜索方式
printf("请输入查找的方式: 1.按姓名查找 2.按电话号码查找\n");
//接收用户的搜索方式
scanf("%d",&no);
if (no==1) {
//请用户输入要查找的姓名
printf("请输入要查找到姓名:\n");
scanf("%s",searchName);
for (int i=0; i&contactC i++) {
if (!strcmp(searchName,contact[i].name)) {
printf("您查找的联系人为:\n");
printf("%d\t%s\t%s\n",i+1,contact[i].name,contact[i].tel);
}else if(no==2){
//请用户输入要查找的电话号码
printf("请输入要查找的电话号码:\n");
scanf("%s",searchTel);
for (int i=0; i&contactC i++) {
if (!strcmp(searchTel,contact[i].tel)) {
printf("您查找的联系人为:\n");
printf("%d\t%s\t%s\n",i+1,contact[i].name,contact[i].tel);
printf("非法输入!\n");
if (!flag) {
printf("很抱歉!小伙伴不在通讯录中!\n");
//退出系统
void quit(){
printf("系统正在退出...\n");
printf("系统已经退出!\n");
//联系人写入文件
void writeFile(){
//定义文件指针
FILE *fp = fopen(path, "wb");
if (fp!=NULL) {
//写入联系人个数
fwrite(&contactCount, sizeof(contactCount), 1, fp);
//写入每个联系人
for (int i=0; i&contactC i++) {
fwrite(&contact[i], sizeof(Person),1, fp);
fclose(fp);
没有更多推荐了,
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!拒绝访问 | www.wangchao.net.cn | 百度云加速
请打开cookies.
此网站 (www.wangchao.net.cn) 的管理员禁止了您的访问。原因是您的访问包含了非浏览器特征(a14cc6-ua98).
重新安装浏览器,或使用别的浏览器通讯录管理系统源代码(c语言)-360文档中心
360文档中心免费免积分下载,各行业
知识、技术、信息等word文档下载网站
通讯录管理系统源代码(c语言)
通讯录管理系统源代码(c语言)#include "time.h" #include#include#include#includestruct Telephone{char name[20];char addrass[20];char zip[20];char telephone[20];char QQ[20];char email[30];char tean[5];struct Telephone *};typedef struct Telephone TEL;struct passwd{char usename[18];char password[18];struct passwd *};struct passwd *head1=NULL;TEL *head=NULL;void showmenu();
//主菜单void Appenditem();
//添加信息void print();
//输出信息void Finditem1();
//查找信息( 按姓名 )void Removeitem();
//删除信息
void modify();
//删除信息 void Save();
//保存到文件void Open();
//打开文件void dljm();
//产品信息void open();
//选择void jssm();
//统计总数和各分组的人数void time1();
//获取系统时间void
//查找信息(按分组) void czjm();
//查找菜单void xgmm();
//密码文件void denglujm();
//登录界面void login();
//注册密码账号void menu() ;
//菜单void Savepwd();
//保存密码账号void modifypasswd();void denglujm()//登录界面{int i,k,j=0;struct passwd *p;char username1[15],pwd[28],system("color 0f");for(i=0;i<3;i++){printf("\n\t\t\t\t
====================================== \n\n");printf("\t\t\t\t
╭⌒╮¤      今後天氣多雲閒晴`` \n"); printf("\t\t\t\t
╭╭ ⌒╮ ●╭○╮ 守的雲開閒見日月. \n"); printf("\t\t\t\t
╰ ----╯/█\\∨█\\  緣在天意.
\n");printf("\t\t\t\t
~~~~~~~~~~∏~~∏~~~~~~~~~~~.份在人爲 \n"); printf("\t\t\t\t
====================================== \n");printf("\n\n
管理员登陆");printf("\n\n
请输入账号:");scanf("%s",username1);printf("\n
请输入密码:");k=0;ch='0';while(ch!='\r'){ch=getch();if(ch=='\r')printf("*");pwd[k]=k++;}pwd[k]='\0';for(p=head1->p!=NULL;p=p->next){
if((strcmp(p->usename,username1)==0)&&(strcmp(p->password,pwd)==0)){j=1;dljm();}}if(p==NULL&&j==0){system("cls");printf("\a");printf("\n\t用户名密码错误!\n\t请重新输入账号密码!");denglujm();}}}main(){menu();}void menu() //主函数 {char c
免费下载该文档:
通讯录管理系统源代码(c语言)的相关文档搜索
通讯录管理系统源程序(c语言)_工学_高等教育_教育专区 暂无评价|0人阅读|0次下载|举报文档通讯录管理系统源程序(c语言)_工学_高等教育_教育专区。#include&...C语言程序设计实训报告之通... 20页 5财富值 C#扫雷源代码 16页 2财富值 ...课程实训报告 1 题目与要求 1.1 问题提出 本人计划编写一个通讯录管理系统。通讯...个人通讯录管理系统C语言源程序(优秀版)_工学_高等教育_教育专区。个人通讯录管理系统C语言源程序 获得98分 #include &stdio.h& /*头文件*/ #include &stdlib...C语言通讯录管理系统程序代码_计算机软件及应用_IT/计算机_专业资料。C语言通讯录...源代码 #include&stdio.h& #include&stdlib.h& #include&string.h& #define...C语言通讯录管理系统源代码 - 副本_管理学_高等教育_教育专区。 /*通讯录管理系统源代码*/ #include&stdio.h& #inc /*通讯录管理系统源代码*/ #include&...通讯录管理系统(C语言) - 说 明 1、设计的目的 1)复习巩固 C 语言的基础知识,进一步加深对 C 语言编程的理解和掌握; 2)利用所学知识,理论和实际结合,利用...C语言通讯录管理系统程序代码 - ---...C 语言程序设计报告一.课题通讯录管理系统 二.设计方案简介为了帮助广大人群解决...主函数流程图 七.源代码 #include &stdio.h & #include &stdlib.h& #...个人通讯录管理系统C语言源程序(优秀版)[1]_计算机软件及应用_IT/计算机_专业...通讯录管理系统源代码(c... 9页 3下载券
C语言,课程设计学生通讯... 10...c语言通讯录管理系统 - #includestdio.h #includestring.h #include &stdlib.h& //用到该头文件中的清屏函数 void _menu(); /...c语言课程设计报告通讯录
var sogou_ad_id=731549;
var sogou_ad_height=160;
var sogou_ad_width=690;}

我要回帖

更多关于 c语言中打开文件 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信