C语言通讯录课设完整版

高级语言程序设计

课程设计任务书

                                            课程名称:________________________

                                            设计题目:________________________

                                            专业班级:________________________

                                            学    号:________________________

                                            学生姓名:________________________

                                            指导老师:________________________

                                            起止日期:________________________

目录

第一章:设计题目与思路

1.1设计题目

1.2设计思路

第二章:数据结构设计描述

2.1 联系人结构体和通讯录结构体的设计

2.2 常量的定义和作用

2.3.调用的头文件

第三章:功能设计

3.1 系统功能模块描述

3.2 新建联系人函数流程图

3.3查找联系人函数流程图

3.4修改联系人函数流程图

3.5程序总流程图简介

第四章:系统测试

第五章:课程设计总结

5.1遇到的问题

5.2心得体会

源码展示


                              

第一章:设计题目与思路

1.1设计题目

通讯录

1.2设计思路

  1. 通讯录课程设计涉及知识:结构体,数组,函数,指针,文件操作以及图形化节目的使用。
  2. 程序说明:设计一个通讯录,能够实现通讯录的基本操作,并且保持在文件中,此通讯录提供以下主要功能:
  1. 通讯录欢迎界面,实现对所有函数的调用
  2. 菜单设计,实现通讯录功能选择
  3. 初始化通讯录,并且加载文件信息到通讯录
  4. 检查通讯录空间是否已满,扩容通讯录
  5. 加载通讯录背景图片
  6. 录入联系人信息
  7. 查询联系人信息
  8. 修改联系人信息
  9. 浏览所有联系人信息
  10. 保存通讯录到文件
  11. 销毁动态开辟空间
  12. 退出通讯录
  1. 各菜单项功能

菜单项如下图所示:

  1. 初始化通讯录:自动加载文件中的联系人,并且生成初始通讯录结构体并且分配初始空间。
  2. 新建联系人:输入联系人的姓名,籍贯,电话号码1,电话号码2以及邮箱。
  3. 浏览通讯录:打印通讯录所有联系人信息。
  4. 修改联系人:输入联系人姓名,修改其信息。
  5. 查询联系人:输入联系人姓名,显示此联系人信息。
  6. 保存通讯录:将通讯录所有联系人信息保存到文件。
  7. 退出通讯录:退出通讯录,结束程序,给出是否保存通讯录的提示并且自动调用销毁动态空间的函数。

功能函数声明实例:

void Initdiretory(Dire* dire);//初始化顺序表存储联系人信息

void Input_message(Dire* dire);//信息录入功能

void Browse_message(const Dire* dire);//信息浏览功能

void Check_message(Dire* dire);//信息查询功能

void Redact_message(Dire* dire);//信息修改功能

void Save_Directory(Dire* dire);//将通讯录保存到文件中

辅助函数声明实例:

void menu();//系统菜单

void New_space(Dire* dire);//检查空间是否已满,若已满分配新空间

void Load_Directory(Dire* dire);//将文件中已经存在的通讯录加载到现有通讯录中

void Destory(Dire* dire);//销毁通讯录,注意要在保存之后,会自动进行保存

void Welcome();//通讯录欢迎图形界面

void loadimage(int x);//加载图片的函数

第二章:数据结构设计描述

2.1 联系人结构体和通讯录结构体的设计

联系人结构体:

typedef struct Contact//定义联系人结构体

{

char name[MAX_NAME];//姓名

char address[MAX_ADDRESS];//籍贯/地址

char phone_number1[MAX_PHONENUM];//电话号码1

char phone_number2[MAX_PHONENUM];//电话号码2

char elec_mailbox[MAX_ELECMAILBOX];//电子邮箱

}Contact;

通讯录结构体

typedef struct Directory

{

Contact* directory;//指向通讯录的指针

int capacity;//通讯录顺序表的容量

int contact_amount;//通讯录当前的联系人数量

}Dire;

其中,联系人采取的是顺序存储的方法,并且通过链表让他们形成线性结构,便于调用每个联系人的信息,能够动态地申请空间,并且更加方便我们对于增删查改操作的实现。

2.2 常量的定义和作用

#define INIT_SIZE 3//联系人顺序表初始空间为3个联系人结构体大小

#define NEW_SIZE 5//联系人顺序表每次追加的空间为2个联系人结构体大小

#define MAX_NAME 10//名字的最大长度

#define MAX_ADDRESS 80//籍贯最大长度

#define MAX_PHONENUM 11//电话号码最大长度

#define MAX_ELECMAILBOX 50//电子邮箱最大长度

之所以使用这么多常量去代替通讯录中一些关键值,是为了在后续对于通讯录的更新中能够更加方便地进行操作。

2.3.调用的头文件

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<graphics.h>

#include<conio.h>

#include<string.h>

第三章:功能设计

3.1 系统功能模块描述

 

3.2 新建联系人函数流程图

 

3.3查找联系人函数流程图

 

3.4修改联系人函数流程图

 

以上3.2到3.4,展示了三个较为复杂的函数的流程图,有助于我们对于功能实现流程的理解,接下来展示程序总流程的简介。

3.5程序总流程图简介

 

第四章:系统测试

  1. 进入通讯录菜单

 

1.鼠标左击初始化联系人

 

2.点击新建联系人

 

点击每一项,输入信息,点击确定

 

点击确定,完成新建

 

3.返回菜单,点击查找联系人,输入姓名 

屏幕显示联系人相关信息,完成查找联系人

 

  1. 点击修改联系人,输入姓名

点击确定,输入修改信息,完成修改联系人

 

  1. 点击浏览通讯录,所有联系人信息被显示,此时只有一个联系人

 

  1. 点击保存通讯录,通讯录信息被保存至文件

 

第五章:课程设计总结

5.1遇到的问题

  1. 对于图形化函数使用不过熟练,界面不够美观。
  2. 函数功能不够完善,比如查找和修改联系人只能通过姓名查找到联系人,另外同名联系人的问题没有得到解决。
  3. 对于文件操作不过熟练,常常忘记一些函数的作用。

5.2心得体会

通过这次通讯录的设计,让我能够充分使用所有知识,进一步了解编程知识的奥妙。对于自身的缺陷有了深刻的认识,认为能够更好地改善自我。

源码展示

directory.h//放置函数声明和常量以及头文件引用

#pragma once

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<graphics.h>

#include<conio.h>

#include<string.h>

#define INIT_SIZE 3//联系人顺序表初始空间为3个联系人结构体大小

#define NEW_SIZE 5//联系人顺序表每次追加的空间为2个联系人结构体大小

#define MAX_NAME 10//名字的最大长度

#define MAX_ADDRESS 80//籍贯最大长度

#define MAX_PHONENUM 11//电话号码最大长度

#define MAX_ELECMAILBOX 50//电子邮箱最大长度

typedef struct Contact//定义联系人结构体

{

char name[MAX_NAME];//姓名

char address[MAX_ADDRESS];//籍贯/地址

char phone_number1[MAX_PHONENUM];//电话号码1

char phone_number2[MAX_PHONENUM];//电话号码2

char elec_mailbox[MAX_ELECMAILBOX];//电子邮箱

}Contact;

typedef struct Directory

{

Contact* directory;//指向通讯录的指针

int capacity;//通讯录顺序表的容量

int contact_amount;//通讯录当前的联系人数量

}Dire;

void menu();//系统菜单

void Initdiretory(Dire* dire);//初始化顺序表存储联系人信息

void New_space(Dire* dire);//检查空间是否已满,若已满分配新空间

void Input_message(Dire* dire);//信息录入功能

void Browse_message(const Dire* dire);//信息浏览功能

void Check_message(Dire* dire);//信息查询功能

void Redact_message(Dire* dire);//信息修改功能

void Load_Directory(Dire* dire);//将文件中已经存在的通讯录加载到现有通讯录中

void Save_Directory(Dire* dire);//将通讯录保存到文件中

void Destory(Dire* dire);//销毁通讯录,注意要在保存之后,会自动进行保存

void Welcome();//通讯录欢迎图形界面

void loadimage(int x);//加载图片的函数

directory.c//放置所有函数的实现代码

#define _CRT_SECURE_NO_WARNINGS 1

#include"directory.h"

void loadimage(int x)//图片载入函数

{

if (x == 1)

{

IMAGE image;

loadimage(&image, "./image.jpg ");

putimage(0, 0, &image);

}

else

{

IMAGE image;

loadimage(&image, "./image2.jpg ");

putimage(0, 0, &image);

}

}

void Welcome()

{

Dire dire;

aa:;

initgraph(800, 500, SHOWCONSOLE);

setbkcolor(WHITE);

cleardevice();

loadimage(1);

setbkmode(TRANSPARENT);

settextcolor(BLACK);

settextstyle(50, 20, "楷体");

outtextxy(100, 80, "通");

outtextxy(100, 130, "讯");

outtextxy(100, 180, "程");

outtextxy(100, 230, "序");

outtextxy(100, 280, "设");

outtextxy(100, 330, "计");

setfillcolor(RGB(148, 186, 222));

fillrectangle(200, 50, 600, 90);

settextstyle(30, 20, "楷体");

outtextxy(260, 55, "初始化通讯录");

fillrectangle(200, 100, 600, 140);

settextstyle(30, 20, "楷体");

outtextxy(270, 105, "新建联系人");

fillrectangle(200, 150, 600, 190);

settextstyle(30, 20, "楷体");

outtextxy(270, 155, "浏览通讯录");

fillrectangle(200, 200, 600, 240);

settextstyle(30, 20, "楷体");

outtextxy(270, 205, "修改联系人");

fillrectangle(200, 250, 600, 290);

settextstyle(30, 20, "楷体");

outtextxy(270, 255, "查询联系人");

fillrectangle(200, 300, 600, 340);

settextstyle(30, 20, "楷体");

outtextxy(270, 305, "保存通讯录");

fillrectangle(200, 350, 600, 390);

settextstyle(30, 20, "楷体");

outtextxy(270, 355, "退出通讯录");

//根据鼠标在不同位置的左击执行不同的函数

while (1)

{

MOUSEMSG msg = GetMouseMsg();

if (msg.x > 200 && msg.x < 600 && msg.y>50 && msg.y < 90)

{

setlinecolor(RED);

rectangle(200, 50, 600, 90);

if (msg.uMsg == WM_LBUTTONDOWN)

{

Initdiretory(&dire);//初始化通讯录

goto aa;

}

}

else if (msg.x > 200 && msg.x < 600 && msg.y>100 && msg.y < 140)

{

rectangle(200, 100, 600, 140);

if (msg.uMsg == WM_LBUTTONDOWN)

{

Input_message(&dire);//信息录入

goto aa;

}

}

else if (msg.x > 200 && msg.x < 600 && msg.y>150 && msg.y < 190)

{

rectangle(200, 150, 600, 190);

if (msg.uMsg == WM_LBUTTONDOWN)

{

Browse_message(&dire);//浏览通讯录

goto aa;

}

}

else if (msg.x > 200 && msg.x < 600 && msg.y>200 && msg.y < 240)

{

rectangle(200, 200, 600, 240);

if (msg.uMsg == WM_LBUTTONDOWN)

{

Redact_message(&dire);//查询联系人

goto aa;

}

}

else if (msg.x > 200 && msg.x < 600 && msg.y>250 && msg.y < 290)

{

rectangle(200, 250, 600, 290);

if (msg.uMsg == WM_LBUTTONDOWN)

{

Check_message(&dire);//修改联系人

goto aa;

}

}

else if (msg.x > 200 && msg.x < 600 && msg.y>300 && msg.y < 340)

{

rectangle(200, 300, 600, 340);

if (msg.uMsg == WM_LBUTTONDOWN)

{

Save_Directory(&dire);//保存通讯录

goto aa;

}

}

else if (msg.x > 200 && msg.x < 600 && msg.y>350 && msg.y < 390)

{

rectangle(200, 350, 600, 390);

if (msg.uMsg == WM_LBUTTONDOWN)//退出通讯录

{

HWND hwnd = GetHWnd();

MessageBox(hwnd, "请确定通讯录已保存", "提示", MB_OKCANCEL);

Destory(&dire);

return;

}

}

}

}

void Initdiretory(Dire* dire)

{

dire->directory = (Contact*)malloc(INIT_SIZE * sizeof(Contact));//初始化是给其分配INIT_SIZE个空间

if (dire->directory == NULL)

{

HWND hwn1 = GetHWnd();

MessageBox(hwn1, "初始化失败", "初始化通讯录", MB_OKCANCEL);

return;

}

dire->capacity = INIT_SIZE;//总容量为INIT_SIZE

dire->contact_amount = 0;//当前联系人数量为0

FILE* fp = fopen("Directory.txt", "rb");

if (fp == NULL)

{

HWND hwn = GetHWnd();

MessageBox(hwn, "通讯录初始化失败", "初始化通讯录", MB_OKCANCEL);

return;

}

Contact tmp = { 0 };

while (fread(&tmp, sizeof(Contact), 1, fp))

{

New_space(dire);

dire->directory[dire->contact_amount] = tmp;

//将文件中的联系人复制到顺序表相应位置

dire->contact_amount++;

}

HWND hwnd = GetHWnd();

MessageBox(hwnd, "通讯录初始化成功\n原通讯录加载成功", "初始化通讯录", MB_OKCANCEL);

}

void New_space(Dire* dire)

{

if (dire->capacity - 1 == dire->contact_amount)//如果容量已满

{

Contact* tmp = (Contact*)realloc(dire->directory, (dire->capacity + NEW_SIZE) * sizeof(Contact));

//给其分配新的空间

if (tmp == NULL)

{

HWND hwnd = GetHWnd();

MessageBox(hwnd, "内存拓展失败", "内存拓展", MB_OKCANCEL);

exit(0);

}

dire->directory = tmp;

dire->capacity = dire->capacity + NEW_SIZE;

}

}

void Input_message(Dire* dire)//信息录入功能

{

New_space(dire);

//为图形化录入设置画面

initgraph(800, 500);

setbkcolor(WHITE);

cleardevice();

loadimage(2);

setbkmode(TRANSPARENT);

settextcolor(BLACK);

settextstyle(50, 20, "楷体");

outtextxy(250, 230, "请");

outtextxy(250, 280, "输");

outtextxy(250, 330, "入");

outtextxy(250, 380, "信");

outtextxy(250, 430, "息");

setfillcolor(RGB(131, 98, 170));

fillrectangle(320, 240, 620, 270);

settextstyle(30, 20, "楷体");

settextcolor(RED);

outtextxy(340, 240, "输入姓名");

fillrectangle(320, 280, 620, 310);

settextstyle(30, 20, "楷体");

settextcolor(RED);

outtextxy(340, 280, "输入籍贯");

fillrectangle(320, 320, 620, 350);

settextstyle(30, 20, "楷体");

settextcolor(RED);

outtextxy(340, 320, "输入电话号码1");

fillrectangle(320, 360, 620, 390);

settextstyle(30, 20, "楷体");

settextcolor(RED);

outtextxy(340, 360, "输入电话号码2");

fillrectangle(320, 400, 620, 430);

settextstyle(30, 20, "楷体");

settextcolor(RED);

outtextxy(340, 400, "输入电子邮箱");

setfillcolor(GREEN);

fillrectangle(640, 400, 720, 450);

settextstyle(30, 20, "楷体");

settextcolor(BLACK);

outtextxy(640, 410, "确定");

int x = 0;

while (1)

{

MOUSEMSG msg = GetMouseMsg();

if (msg.x > 320 && msg.x < 620 && msg.y>240 && msg.y < 270)

{

setlinecolor(GREEN);

rectangle(320, 240, 620, 270);

if (msg.uMsg == WM_LBUTTONDOWN)

{

char ss[MAX_NAME] = { 0 };

InputBox(ss, MAX_NAME, "请输入姓名");

//outtextxy(500, 25, ss);

memcpy(dire->directory[dire->contact_amount].name, ss, MAX_NAME);

x++;

}

}

else if (msg.x > 320 && msg.x < 620 && msg.y>280 && msg.y < 310)

{

rectangle(320, 280, 620, 310);

if (msg.uMsg == WM_LBUTTONDOWN)

{

char ss[MAX_ADDRESS] = { 0 };

InputBox(ss, MAX_ADDRESS, "请输入籍贯");

//outtextxy(500, 25, ss);

memcpy(dire->directory[dire->contact_amount].address, ss, MAX_ADDRESS);

x++;

}

}

else if (msg.x > 320 && msg.x < 620 && msg.y>320 && msg.y < 350)

{

rectangle(320, 320, 620, 350);

if (msg.uMsg == WM_LBUTTONDOWN)

{

char ss[MAX_PHONENUM] = { 0 };

InputBox(ss, MAX_PHONENUM, "请输入电话号码1");

//outtextxy(500, 25, ss);

memcpy(dire->directory[dire->contact_amount].phone_number1, ss, MAX_PHONENUM);

x++;

}

}

else if (msg.x > 320 && msg.x < 620 && msg.y>360 && msg.y < 390)

{

rectangle(320, 360, 620, 390);

if (msg.uMsg == WM_LBUTTONDOWN)

{

char ss[MAX_PHONENUM] = { 0 };

InputBox(ss, MAX_PHONENUM, "请输入电话号码2");

//outtextxy(500, 25, ss);

memcpy(dire->directory[dire->contact_amount].phone_number2, ss, MAX_PHONENUM);

x++;

}

}

else if (msg.x > 320 && msg.x < 620 && msg.y>400 && msg.y < 430)

{

rectangle(320, 400, 620, 430);

if (msg.uMsg == WM_LBUTTONDOWN)

{

char ss[MAX_ELECMAILBOX] = { 0 };

InputBox(ss, MAX_ELECMAILBOX, "请输入电子邮箱");

//outtextxy(500, 25, ss);

memcpy(dire->directory[dire->contact_amount].elec_mailbox, ss, MAX_ELECMAILBOX);

x++;

}

}

else if (msg.x > 640 && msg.x < 720 && msg.y>400 && msg.y < 450)

{

setfillcolor(BLACK);

rectangle(640, 400, 720, 450);

if (msg.uMsg == WM_LBUTTONDOWN)

{

goto mm;

}

}

}

mm:;

if (x >= 5)

{

dire->contact_amount++;

HWND hwnd = GetHWnd();

MessageBox(hwnd, "联系人添加成功", "新建联系人", MB_OKCANCEL);

}

else

{

HWND hwnd = GetHWnd();

MessageBox(hwnd, "联系人添加失败", "新建联系人", MB_OKCANCEL);

return;

}

}

//

//

void Browse_message(const Dire* dire)//信息浏览

{

putchar('\n');

putchar('\n');

printf("当前通讯录信息如下\n\n");

for (int i = dire->contact_amount - 1; i >= 0; i--)

{

//在控制台打印所有联系人信息

printf("姓名: ");

printf("%s\n", (dire->directory + i)->name);

printf("籍贯: ");

printf("%s\n", (dire->directory + i)->address);

printf("电话号码1: ");

printf("%s\n", (dire->directory + i)->phone_number1);

printf("电话号码2: ");

printf("%s\n", (dire->directory + i)->phone_number2);

printf("电子邮箱: ");

printf("%s\n", (dire->directory + i)->elec_mailbox);

putchar('\n');

putchar('\n');

}

}

void Check_message(Dire* dire)//信息查询功能(根据联系人姓名)

{

int flag = 0;

initgraph(500, 500);

setbkcolor(GREEN);

cleardevice();

int i = 0;

char str[MAX_NAME] = { 0 };

setbkmode(TRANSPARENT);

InputBox(str, MAX_NAME, "请输入联系人姓名");

settextstyle(30, 0, "宋体");

settextcolor(BLACK);

for (i = dire->contact_amount - 1; i >= 0; i--)

{

if (memcmp(str, (dire->directory + i)->name, MAX_NAME) == 0)//若满足字符串相等,就找到该联系人

{

flag = 1;

Contact ss = dire->directory[i];

outtextxy(50, 0, "查询联系人信息如下");

outtextxy(50, 50, "姓名:");

outtextxy(50, 100, "籍贯:");

outtextxy(50, 150, "电话号码1:");

outtextxy(50, 200, "电话号码2:");

outtextxy(50, 250, "电子邮箱:");

settextcolor(RED);

fillrectangle(75, 300, 150, 330);

outtextxy(75, 300, "确认");

outtextxy(150, 50, ss.name);

outtextxy(150, 100, ss.address);

outtextxy(200, 150, ss.phone_number1);

outtextxy(200, 200, ss.phone_number2);

outtextxy(200, 250, ss.elec_mailbox);

while (1)

{

MOUSEMSG msg = GetMouseMsg();

if (msg.x > 75 && msg.x < 150 && msg.y>300 && msg.y < 330)

{

setlinecolor(BLACK);

rectangle(75, 300, 150, 330);

if (msg.uMsg == WM_LBUTTONDOWN)

{

return;

}

}

}

}

}

if (flag == 0)

{

HWND hwnd = GetHWnd();

MessageBox(hwnd, "通讯录查无此人", "查询联系人", MB_OKCANCEL);

}

}

void Redact_message(Dire* dire)//信息修改功能

{

char str[MAX_NAME] = { 0 };

InputBox(str, MAX_NAME, "请输入姓名");

int i = 0;

for (i = dire->contact_amount - 1; i >= 0; i--)

{

if (memcmp(str, (dire->directory + i)->name, MAX_NAME) == 0)//若满足字符串相等,就找到该联系人

{

//设计信息修改界面

initgraph(800, 500);

setbkcolor(RGB(72, 29, 54));

cleardevice();

settextstyle(40, 0, "宋体");

settextcolor(BLACK);

setfillcolor(RED);

outtextxy(240, 20, "请选择修改信息");

fillrectangle(250, 100, 350, 150);

fillrectangle(400, 100, 500, 150);

fillrectangle(250, 180, 350, 230);

fillrectangle(400, 180, 500, 230);

fillrectangle(250, 250, 350, 300);

setfillcolor(GREEN);

fillrectangle(400, 250, 500, 300);

setbkmode(TRANSPARENT);

outtextxy(250, 100, "姓名");

outtextxy(400, 100, "籍贯");

outtextxy(250, 180, "号码1");

outtextxy(400, 180, "号码2");

outtextxy(250, 250, "邮箱");

outtextxy(400, 250, "确认");

break;

}

}

while (1)//根据鼠标现在需要修改的信息,点击确定退出修改

{

MOUSEMSG msg = GetMouseMsg();

if (msg.x > 250 && msg.x < 350 && msg.y>100 && msg.y < 150)

{

setlinecolor(BLACK);

rectangle(250, 100, 350, 150);

if (msg.uMsg == WM_LBUTTONDOWN)

{

char ss[MAX_NAME] = { 0 };

InputBox(ss, MAX_NAME, "请输入修改姓名");

outtextxy(500, 25, ss);

memcpy(dire->directory[i].name, ss, MAX_NAME);

}

}

else if (msg.x > 400 && msg.x < 500 && msg.y>100 && msg.y < 150)

{

rectangle(400, 100, 500, 150);

if (msg.uMsg == WM_LBUTTONDOWN)

{

char ss[MAX_ADDRESS] = { 0 };

InputBox(ss, MAX_ADDRESS, "请输入籍贯");

outtextxy(500, 25, ss);

memcpy(dire->directory[i].address, ss, MAX_ADDRESS);

}

}

else if (msg.x > 250 && msg.x < 350 && msg.y>180 && msg.y < 230)

{

rectangle(250, 180, 350, 230);

if (msg.uMsg == WM_LBUTTONDOWN)

{

char ss[MAX_PHONENUM] = { 0 };

InputBox(ss, MAX_PHONENUM, "请输入电话号码1");

outtextxy(500, 25, ss);

memcpy(dire->directory[i].phone_number1, ss, MAX_PHONENUM);

}

}

else if (msg.x > 400 && msg.x < 500 && msg.y>180 && msg.y < 230)

{

rectangle(400, 180, 500, 230);

if (msg.uMsg == WM_LBUTTONDOWN)

{

char ss[MAX_PHONENUM] = { 0 };

InputBox(ss, MAX_PHONENUM, "请输入电话号码1");

outtextxy(500, 25, ss);

memcpy(dire->directory[i].phone_number2, ss, MAX_PHONENUM);

}

}

else if (msg.x > 250 && msg.x < 350 && msg.y>250 && msg.y < 300)

{

rectangle(250, 250, 350, 300);

if (msg.uMsg == WM_LBUTTONDOWN)

{

char ss[MAX_ELECMAILBOX] = { 0 };

InputBox(ss, MAX_ELECMAILBOX, "请输入电子邮箱");

outtextxy(500, 25, ss);

memcpy(dire->directory[i].elec_mailbox, ss, MAX_ELECMAILBOX);

}

}

else if (msg.x > 400 && msg.x < 500 && msg.y>250 && msg.y < 300)

{

rectangle(400, 250, 500, 300);

if (msg.uMsg == WM_LBUTTONDOWN)

{

HWND hwnd = GetHWnd();

MessageBox(hwnd, "信息修改成功", "修改联系人", MB_OKCANCEL);

return;

}

}

}

}

void Save_Directory(Dire* dire)

{

FILE* pf = fopen("Directory.txt", "wb");//以二进制只写的方式打开文件

if (!pf)//若打开失败,退出程序

{

HWND hwnd = GetHWnd();

MessageBox(hwnd, "打开失败", "保存通讯录", MB_OKCANCEL);

exit(0);

}

for (int i = 0; i < dire->contact_amount; i++)

{

fwrite(&(dire->directory[i]), sizeof(Contact), 1, pf);//依次将信息写入

}

fclose(pf);//写完就关闭文件

pf = NULL;//置为NULL

HWND hwnd = GetHWnd();

MessageBox(hwnd, "保存成功", "保存通讯录", MB_OKCANCEL);

}

void Destory(Dire* dire)//销毁通讯录动态开辟的空间

{

free(dire->directory);

dire->directory = NULL;

dire->capacity = 0;

dire->contact_amount = 0;

}

//test.cpp  调用所有函数的mian函数

#define _CRT_SECURE_NO_WARNINGS 1

#include"directory.h"

int main()

{

Welcome();//负责全局调用函数的主函数

return 0;

}

  • 2
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
C语言计任务书(4) 一、题目:通讯录管理 二、目的与要求 1. 目的: (1)基本掌握面向过程程序计的基本思路和方法; (2)达到熟练掌握C语言的基本知识和技能; (3)能够利用所学的基本知识和技能,解决简单的程序计问题 2. 要求 基本要求: 1.         要求利用C语言面向过程的编程思想来完成系统的计; 2.       突出C语言的函数特征,以多个函数实现每一个子功能; 3.         画出功能模块图; 4.         具有清晰的程序流程图和数据结构的详细定义; 5.       熟练掌握C语言对文件的各种操作。 创新要求: 在基本要求达到后,可进行创新计,如系统用户功能控制,对管理员级和一般级别的用户系统功能操作不同 三、信息描述 有关该系统基本信息的描述,如:姓名、电话、城市和邮编等。 四、功能描述 1.       名单基本信息(姓名,城市,电话,邮编等)的录入,并存放在文件当中。 2.       基本信息的查询与修改。 3.       记录的添加和删除。 4.       对同一类型记录的查找:如查找同一城市的记录或同一省份的记录。 五、解决方案 1.       分析程序的功能要求,划分程序功能模块。 2.       画出系统流程图。 3.       代码的编写。定义数据结构和各个功能子函数。 4.       程序的功能调试。 5.       完成系统总结报告以及使用说明书 六、进度安排 此次计时间为一周或两周,分四个阶段完成: 1.       分析计阶段。指导教师应积极引导学生自主学习和钻研问题,明确计要求,找出实现方法,按照需求分析、总体计、详细计这几个步骤进行。 2.       编码调试阶段:根据计分析方案编写C代码,然后调试该代码,实现题要求的功能。 3.       总结报告阶段:总结计工作,写出计说明书,要求学生写出需求分析、总体计、详细计、编码、测试的步骤和内容。 4.       考核阶段。 七、撰写计报告或计总结 计报告要求: 总结报告包括需求分析、总体计、详细计、编码(详细写出编程步骤)、测试的步骤和内容、计总结、参考资料等,不符合以上要求者,则本次计以不及格记。 八、参考资料  《C语言程序计教程》   网上相关资料(....略)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值