用c语言编写通讯录管理程序
实现功能:1、通过提示菜单选择可以进行的操作2、将人员的信息存入文件中,并命名为PersonInfo.txt3、在本系统中可以进行管理系统包含的基本操作,其中包括:a)查...
实现功能:
1、通过提示菜单选择可以进行的操作
2、将人员的信息存入文件中,并命名为PersonInfo.txt
3、在本系统中可以进行管理系统包含的基本操作,其中包括:
a) 查看所有人员的信息
b) 输入一个人员的人员号,从当前人员中进行查找,如果找到则显示该人员的相关信息,如果没有找到则给出提示信息
c) 添加一个人员的基本信息,通过输入人员号,首先查找是否存在该人员号的人员,如果存在则提示重新输入,否则将该人员按照顺序插入到相应位置
d) 删除一个人员的基本信息,通过输入人员号,首先查找是否存在该人员号的人员,如果存在则将该人员删除,否则给出提示信息,提示该人员不存在
4、人员基本信息包括人员号、姓名、性别、生日、电话和所在地这些简单信息
5、人员信息文件中每一行存放一个人员的信息
哪位大侠救命啊 感激不尽!!!!!!! 展开
1、通过提示菜单选择可以进行的操作
2、将人员的信息存入文件中,并命名为PersonInfo.txt
3、在本系统中可以进行管理系统包含的基本操作,其中包括:
a) 查看所有人员的信息
b) 输入一个人员的人员号,从当前人员中进行查找,如果找到则显示该人员的相关信息,如果没有找到则给出提示信息
c) 添加一个人员的基本信息,通过输入人员号,首先查找是否存在该人员号的人员,如果存在则提示重新输入,否则将该人员按照顺序插入到相应位置
d) 删除一个人员的基本信息,通过输入人员号,首先查找是否存在该人员号的人员,如果存在则将该人员删除,否则给出提示信息,提示该人员不存在
4、人员基本信息包括人员号、姓名、性别、生日、电话和所在地这些简单信息
5、人员信息文件中每一行存放一个人员的信息
哪位大侠救命啊 感激不尽!!!!!!! 展开
3个回答
展开全部
声明: 非原创
/*个人通讯录*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct dataWab{
char name[8];
char telephone[16];
char mobile[16];
char address[16];
char unit[16];
struct dataWab *nextPtr;
}; /*自引用结构,用作通讯录的数据结构*/
typedef struct dataWab DATAWAB;
typedef DATAWAB *DATAWABPTR;
void insertWab(DATAWABPTR*,char[],char[],char[],char[],char[]); /*插入函数*/
void menuWab(void); /*菜单函数*/
void printWab(DATAWABPTR); /*打印所有记录函数*/
void seekWab(DATAWABPTR,char[]); /*查找函数*/
void deleteWab(DATAWABPTR,char[]); /*删除函数*/
void modifyWab(DATAWABPTR,char[]); /*修改函数*/
int test(DATAWABPTR); /*测试函数,测试通讯录内是否有记录*/
void printone(DATAWABPTR); /*打印单条记录函数*/
int controlWab(void); /*程序分支控制函数*/
int main()
{
DATAWABPTR startPtr=NULL;
DATAWABPTR tempPtr;
FILE *fileWab;
char menu; /*菜单操作控制变量*/
char insert; /*插入确认控制变量*/
char modifyName[8]; /*查找时的临时姓名存储*/
char deleteName[8]; /*删除时的临时姓名存储*/
char tempName[8]; /*临时姓名存储*/
char tempTelephone[16]; /*临时电话存储*/
char tempMobile[16]; /*临时手机存储*/
char tempAddress[16]; /*临时地址存储*/
char tempUnit[16]; /*临时单位存储*/
char seekName[8]; /*查找时的临时姓名存储*/
if(!(fileWab=fopen("wab.dat","rb")))
return 0;
tempPtr=(DATAWABPTR)malloc(sizeof(DATAWAB));
while(fread(tempPtr,sizeof(DATAWAB),1,fileWab)==1){
tempPtr->nextPtr=startPtr;
startPtr=tempPtr;
tempPtr=(DATAWABPTR)malloc(sizeof(DATAWAB));
}
fclose(fileWab);
puts("\n\n\t\t欢迎使用个人通讯录1.0\n");
menuWab();
menu=getch();
while(menu!='6'){
switch(menu){
case '1':
printWab(startPtr);
break;
case '2':
while(controlWab()){
printf("\n查找姓名:\n#>");
scanf("%s",seekName);
seekWab(startPtr,seekName);
}
break;
case '3':
while(controlWab()){
puts("\n录入个人信息\n");
printf("姓名:");
scanf("%s",tempName);
printf("\n电话:");
scanf("%s",tempTelephone);
printf("\n手机:");
scanf("%s",tempMobile);
printf("\n地址:");
scanf("%s",tempAddress);
printf("\n单位:");
scanf("%s",tempUnit);
printf("录入正确请按 1 \n#>");
insert=getch();
if(insert=='1')
insertWab(&startPtr,tempName,tempTelephone,tempMobile,
tempAddress,tempUnit);
}
break;
case '4':
while(controlWab()){
printf("\n删除姓名\n#>");
scanf("%s",deleteName);
deleteWab(startPtr,deleteName);
}
break;
case '5':
while(controlWab()){
printf("\n修改姓名\n#>");
scanf("%s",modifyName);
modifyWab(startPtr,modifyName);
}
break;
default:
puts("\n\n输入选项错误,请重新输入\n");
break;
}
menuWab();
menu=getch();
}
if((fileWab=fopen("wab.dat","wb"))==NULL)
return 0;
while(startPtr!=NULL){
fwrite(startPtr,sizeof(DATAWAB),1,fileWab);
startPtr=startPtr->nextPtr;
}
puts("\n\n\t\t谢谢使用个人通讯录1.0,再见\n");
}
void menuWab(void) /*菜单函数*/
{
puts("\t\t\t主菜单");
puts("**********************************************************");
puts("**********************************************************");
puts("**\t<<-1->>所有记录\t\t<<-2->>查找记录\t\t**");
puts("**\t<<-3->>增加记录\t\t<<-4->>删除记录\t\t**");
puts("**\t<<-5->>修改记录\t\t<<-6->>退出程序\t\t**");
puts("**********************************************************");
puts("**********************************************************");
puts("\n请选择 1-6");
printf("#>");
}
void insertWab(DATAWABPTR *tempPtr,char temp2Name[],char temp2Telephone[],
char temp2Mobile[],char temp2Address[],char temp2Unit[])
/*插入函数*/
{
DATAWABPTR newPtr;
newPtr=(DATAWABPTR)malloc(sizeof(DATAWAB));
strcpy(newPtr->name,temp2Name);
strcpy(newPtr->telephone,temp2Telephone);
strcpy(newPtr->mobile,temp2Mobile);
strcpy(newPtr->address,temp2Address);
strcpy(newPtr->unit,temp2Unit);
newPtr->nextPtr=*tempPtr;
*tempPtr=newPtr;
}
void printWab(DATAWABPTR printPtr) /*打印函数*/
{
if(!(test(printPtr))){
printf("\n%8s%16s%16s%16s%16s\n","姓名","电话","手机","住址","单位");
while(printPtr!=NULL){
printf("%8s%16s%16s%16s%16s\n",printPtr->name,printPtr->telephone,
printPtr->mobile,printPtr->address,printPtr->unit);
printPtr=printPtr->nextPtr;
}
}
}
void seekWab(DATAWABPTR seekPtr,char tempName[])
/*查找函数*/
{
if(!(test(seekPtr))){
while(seekPtr!=NULL){
if(!(strcmp(tempName,seekPtr->name))){
printone(seekPtr);
seekPtr=seekPtr->nextPtr;
}
else
seekPtr=seekPtr->nextPtr;
}
}
}
void deleteWab(DATAWABPTR deletePtr,char deleteName[])
/*删除函数*/
{
DATAWABPTR tempPtr,forePtr;
forePtr=deletePtr;
tempPtr=deletePtr->nextPtr;
while(tempPtr!=NULL){
if(!(strcmp(tempPtr->name,deleteName))){
forePtr->nextPtr=tempPtr->nextPtr;
free(tempPtr);
break;
}
else{
forePtr=tempPtr;
tempPtr=tempPtr->nextPtr;
}
}
}
void modifyWab(DATAWABPTR modifyPtr,char modifyName[])
/*修改函数*/
{
if(!(test(modifyPtr))){
while(modifyPtr!=NULL){
if(!(strcmp(modifyName,modifyPtr->name))){
printf("请输入新姓名:");
scanf("%s",modifyPtr->name);
printf("\n请输入新电话:");
scanf("%s",modifyPtr->telephone);
printf("\n请输入新手机:");
scanf("%s",modifyPtr->mobile);
printf("\n请输入新地址:");
scanf("%s",modifyPtr->address);
printf("\n请输入新单位:");
scanf("%s",modifyPtr->unit);
break;
}
else
modifyPtr=modifyPtr->nextPtr;
}
}
}
int test(DATAWABPTR testPtr)
{
if(testPtr==NULL)
puts("通讯录内没有任何记录");
else
return 0;
return 1;
}
void printone(DATAWABPTR printone)
{
printf("\n%8s%16s%16s%16s%16s\n","姓名","电话","手机","住址","单位");
printf("%8s",printone->name);
printf("%16s",printone->telephone);
printf("%16s",printone->mobile);
printf("%16s",printone->address);
printf("%16s\n",printone->unit);
}
int controlWab(void)
{
puts("继续执行请按 1");
if(getch()=='1')
return 1;
return 0;
}
回答者: 虑而后能得 - 助理 二级 2-19 11:36
我来评论>>
提问者对于答案的评价:感激不尽~~评价已经被关闭 目前有 1 个人评价
好
100% (1) 不好
0% (0)
相关内容
• 救命啊! 哪位高手能帮我用C语言编写一个通讯录管理的...
• 3110c 通讯录的问题
• 索爱510c的电话本备份?
• 6120C的电话本能不能通过什么方式转到6500C来
• 关于诺基亚7310c通讯录显示姓名的问题~~~
更多关于c语言编写通讯录管理程序的问题>>
查看同主题问题:高手 语言 通讯录 救命 管理 程序
其他回答 共 4 条
分少啊,没动力,谁会写啊
回答者: 229273121 - 见习魔法师 三级 2-19 10:16
本人的C++通讯录程序代码
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<fstream>
#include<algorithm>
#define SPACE "\t\t\t"
using namespace std;
struct Record{
string name;
string tel;
public:
friend ostream& operator<<(ostream& os,const Record *rec){
return os<<rec->name<<SPACE<<rec->tel<<endl;
};
friend istream& operator>>(istream& is,Record *rec){
is>>rec->name;
is>>rec->tel;
return is;
}
static bool comp(string patten,int type,Record *rec){
switch(type){
case 0: {return rec->name==patten;}break;
case 1: {return rec->tel==patten;}break;
}
return false;
}
static bool isvan(Record *rec){
return (rec->name==""&&rec->tel=="");
}
};
class RecordList:public list<Record*>
{
public:
friend ostream& operator<<(ostream& os,const RecordList &c_rl){
RecordList::const_iterator it=c_rl.begin();
while(it!=c_rl.end()){
os<<*it;
it++;
}
return os;
}
friend istream& operator>>(istream& is,RecordList &rl){
RecordList::const_iterator it;
while(!is.eof()){
Record *prec=new Record;
is>>prec;
if(Record::isvan(prec)) continue;
rl.list<Record*>::push_back(prec);
}
return is;
}
void clear();
iterator erase(iterator pos);
~RecordList(){
this->clear();
}
};
void RecordList::clear(){
RecordList::const_iterator it=this->begin();
while(it!=this->end()){
delete(*it);
it++;
}
this->list<Record*>::clear();
}
RecordList::iterator RecordList::erase(iterator pos){
delete(*pos);
return list<Record*>::erase(pos);
}
class AddressList{
protected:
RecordList recList;
public:
typedef RecordList::iterator Iterator;
//从通信录中寻找一个记录
virtual Iterator findRecord(string patten,int type,Iterator from);
virtual void addRecord(Record* rec);
virtual void removeRecord(Iterator it);
virtual void editRecord(Record* rec,Iterator it);
virtual void saveRecords(ostream& os);
virtual void loadRecords(istream& is);
virtual void addRecords(istream& is);
virtual ~AddressList();
const int size() const{return (int)recList.size();}
const void clear(){recList.clear();}
Iterator begin(){return recList.begin();}
Iterator end() {return recList.end();}
};
AddressList::Iterator AddressList::findRecord(string patten,int type,Iterator from){
Iterator it;
it=from;
while(it!=recList.end()){
if(Record::comp(patten,type,*it)){
return it;
}
it++;
}
return it;
}
void AddressList::addRecord(Record* rec){
recList.push_back(rec);
}
void AddressList::removeRecord(Iterator it){
recList.erase(it);
}
void AddressList::editRecord(Record* rec,Iterator it){
delete(*it);
*it=rec;
}
void AddressList::saveRecords(ostream& os){
os<<recList;
}
void AddressList::loadRecords(istream& is){
is>>recList;
}
void AddressList::addRecords(istream& is){
}
AddressList::~AddressList(){
recList.clear();
}
class AddressBook : public AddressList{
protected:
bool isModified;//通信录是否已被修改还未保存
public:
AddressBook();
virtual ~AddressBook();
//开始通信录的用户界面操作
virtual void start();
//菜单处理函数管理程序的用户界面操作
virtual void handleMenu();
//显示记录
virtual void displayRecords();
//查询记录
virtual void queryRecord();
//添加记录
virtual void addRecord();
//保存记录
virtual void saveRecords();
//读取记录
virtual void loadRecords();
//结束程序
virtual void quit();
//清空当前记录信息
virtual void clear();
protected:
//菜单选择函数
char menuSelect();
//显示表头
void dispTable();
};
AddressBook::AddressBook(){
}
AddressBook::~AddressBook(){;}
char AddressBook::menuSelect(){
char a=0;
cin>>a;
if(a=='y'||a=='Y'){a='1';}
if(a=='n'||a=='N'){a='2';}
return a;
}
void AddressBook::start(){
cout << "\n\t***** 欢迎使用通讯录管理程序 *****";
handleMenu();
}
void AddressBook::handleMenu(){
cout << "\n\n\t\t\t-- 菜单管理 --\n\n";
cout << "\tA -- 添加人员纪录 (Add Record)\n"
<< "\tF -- 查询纪录 (Find Record)\n"
<< "\tD -- 显示纪录 (Display Records)\n"
<< "\tL -- 从文本或标准输入流中加载纪录 (Load Records)\n"
<< "\tC -- 清空当前记录信息\n"
<< "\tS -- 保存记录 (Save Records)\n"
<< "\tQ -- 结束程序 (QUIT)\n";
switch(menuSelect()){
case 'A':
case 'a':addRecord();break;
case 'F':
case 'f':queryRecord();break;
case 'D':
case 'd':displayRecords();break;
case 'L':
case 'l':loadRecords();break;
case 'C':
case 'c':clear();break;
case 'S':
case 's':saveRecords();break;
case 'Q':
case 'q':quit();break;
}
handleMenu();
}
void AddressBook::displayRecords(){
cout<<"姓名"<<SPACE<<"电话"<<endl;
AddressList::saveRecords(cout);
cout<<"一共找到"<<size()<<"个对象。"<<endl;
cout<<"1"<<SPACE<<"返回"<<endl;
cout<<"2"<<SPACE<<"修改"<<endl;
cout<<"3"<<SPACE<<"删除"<<endl;
switch(menuSelect()){
case '1':break;
case '2':{
if(!size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要修改第几个?"<<"1~"<<size()<<endl;
int i;
cin>>i;
if(i<1||i>size()){
break;
}
Record *prec=new Record;
cout<<"姓名:"<<'\n'<<"电话:"<<'\n';
cin>>prec;
Iterator it=recList.begin();
while(i!=1){
it++;
i--;
}
editRecord(prec,it);
}break;
case'3':{
if(!size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要删除第几个?"<<"1~"<<size()<<endl;
int i;
cin>>i;
if(i<1||i>size()){
break;
}
Iterator it=recList.begin();
while(i!=1){
it++;
i--;
}
removeRecord(it);
}break;
}
}
void AddressBook::addRecord(){
string name,tel;
cout << "\n输入名字: ";
cin >> name;
cout << "输入电话: ";
cin >> tel;
Record* temp=new Record;
temp->name=name;
temp->tel=tel;
AddressList::addRecord(temp);
cout<<"是否继续(Y/N)"<<endl;
switch(menuSelect()){
case '1':addRecord();break;
case '2':break;
}
}
void AddressBook::queryRecord(){
cout<<"1"<<SPACE<<"按姓名查找"<<endl;
cout<<"2"<<SPACE<<"按电话查找"<<endl;
int type=-1;
string patten;
switch(menuSelect()){
case '1':{
type=0;
cout<<"请输入姓名"<<endl;
cin>>patten;
}break;
case '2':{
type=1;
cout<<"请输入电话号码"<<endl;
cin>>patten;
}break;
}
Iterator it=begin();
list<Iterator> li;
cout<<"姓名"<<SPACE<<"电话"<<endl;
while((it=findRecord(patten,type,it))!=end()){
cout<<*it;
li.push_back(it);
it++;
}
cout<<"一共找到"<<li.size()<<"个对象。"<<endl;
cout<<"1"<<SPACE<<"返回"<<endl;
cout<<"2"<<SPACE<<"修改"<<endl;
cout<<"3"<<SPACE<<"删除"<<endl;
switch(menuSelect()){
case'1':break;
case'2':{
if(!li.size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要修改第几个?"<<"1~"<<li.size()<<endl;
int i;
cin>>i;
Record *prec=new Record;
cout<<"姓名:"<<'\n'<<"电话:"<<'\n';
cin>>prec;
list<Iterator>::const_iterator it=li.begin();
while(i!=1){
it++;
i--;
}
editRecord(prec,*it);
}break;
case'3':{
if(!li.size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要删除第几个?"<<"1~"<<li.size()<<endl;
int i;
cin>>i;
list<Iterator>::const_iterator it=li.begin();
while(i!=1){
it++;
i--;
}
removeRecord(*it);
}break;
}
}
void AddressBook::saveRecords(){
cout<<"1"<<SPACE<<"使用默认文件名。"<<endl;
cout<<"2"<<SPACE<<"使用自定义文件名。"<<endl;
cout<<"3"<<SPACE<<"返回"<<endl;
switch(menuSelect()){
case '1':{
ofstream file("default",ios::app);
AddressList::saveRecords(file);
file.close();
}break;
case '2':{
cout<<"请输入您定义的文件名:"<<endl;
string fname;
cin>>fname;
ofstream file(fname.c_str(),ios::app);
AddressList::saveRecords(file);
file.close();
}break;
case '3':break;
}
}
void AddressBook::loadRecords(){
cout<<"1"<<SPACE<<"使用默认文件。"<<endl;
cout<<"2"<<SPACE<<"使用自定义文件。"<<endl;
cout<<"3"<<SPACE<<"返回"<<endl;
switch(menuSelect()){
case '1':{
cout<<"1"<<SPACE<<"覆盖当前内容"<<endl;
cout<<"2"<<SPACE<<"追加到当前文件"<<endl;
switch(menuSelect()){
case '1':
AddressList::clear();break;
case '2':break;
}
ifstream file("default");
AddressList::loadRecords(file);
file.close();
}break;
case '2':{
cout<<"请输入文件名:"<<endl;
string fname;
cin>>fname;
ifstream file(fname.c_str());
AddressList::loadRecords(file);
file.close();
}break;
case '3':break;
}
}
void AddressBook::clear(){
cout<<"是否要清除内存中所有内容?(Y/N)"<<endl;
switch(menuSelect()){
case '1':AddressList::clear();break;
case '2':break;
}
}
void AddressBook::quit(){
cout<<"是否要保存文件?(Y/N)"<<endl;
switch(menuSelect()){
case'1':saveRecords();break;
case'2':break;
}
exit(0);
}
int main(int argc, char *argv[])
{
AddressBook a;
a.start();
system("PAUSE");
return EXIT_SUCCESS;
}
/*个人通讯录*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct dataWab{
char name[8];
char telephone[16];
char mobile[16];
char address[16];
char unit[16];
struct dataWab *nextPtr;
}; /*自引用结构,用作通讯录的数据结构*/
typedef struct dataWab DATAWAB;
typedef DATAWAB *DATAWABPTR;
void insertWab(DATAWABPTR*,char[],char[],char[],char[],char[]); /*插入函数*/
void menuWab(void); /*菜单函数*/
void printWab(DATAWABPTR); /*打印所有记录函数*/
void seekWab(DATAWABPTR,char[]); /*查找函数*/
void deleteWab(DATAWABPTR,char[]); /*删除函数*/
void modifyWab(DATAWABPTR,char[]); /*修改函数*/
int test(DATAWABPTR); /*测试函数,测试通讯录内是否有记录*/
void printone(DATAWABPTR); /*打印单条记录函数*/
int controlWab(void); /*程序分支控制函数*/
int main()
{
DATAWABPTR startPtr=NULL;
DATAWABPTR tempPtr;
FILE *fileWab;
char menu; /*菜单操作控制变量*/
char insert; /*插入确认控制变量*/
char modifyName[8]; /*查找时的临时姓名存储*/
char deleteName[8]; /*删除时的临时姓名存储*/
char tempName[8]; /*临时姓名存储*/
char tempTelephone[16]; /*临时电话存储*/
char tempMobile[16]; /*临时手机存储*/
char tempAddress[16]; /*临时地址存储*/
char tempUnit[16]; /*临时单位存储*/
char seekName[8]; /*查找时的临时姓名存储*/
if(!(fileWab=fopen("wab.dat","rb")))
return 0;
tempPtr=(DATAWABPTR)malloc(sizeof(DATAWAB));
while(fread(tempPtr,sizeof(DATAWAB),1,fileWab)==1){
tempPtr->nextPtr=startPtr;
startPtr=tempPtr;
tempPtr=(DATAWABPTR)malloc(sizeof(DATAWAB));
}
fclose(fileWab);
puts("\n\n\t\t欢迎使用个人通讯录1.0\n");
menuWab();
menu=getch();
while(menu!='6'){
switch(menu){
case '1':
printWab(startPtr);
break;
case '2':
while(controlWab()){
printf("\n查找姓名:\n#>");
scanf("%s",seekName);
seekWab(startPtr,seekName);
}
break;
case '3':
while(controlWab()){
puts("\n录入个人信息\n");
printf("姓名:");
scanf("%s",tempName);
printf("\n电话:");
scanf("%s",tempTelephone);
printf("\n手机:");
scanf("%s",tempMobile);
printf("\n地址:");
scanf("%s",tempAddress);
printf("\n单位:");
scanf("%s",tempUnit);
printf("录入正确请按 1 \n#>");
insert=getch();
if(insert=='1')
insertWab(&startPtr,tempName,tempTelephone,tempMobile,
tempAddress,tempUnit);
}
break;
case '4':
while(controlWab()){
printf("\n删除姓名\n#>");
scanf("%s",deleteName);
deleteWab(startPtr,deleteName);
}
break;
case '5':
while(controlWab()){
printf("\n修改姓名\n#>");
scanf("%s",modifyName);
modifyWab(startPtr,modifyName);
}
break;
default:
puts("\n\n输入选项错误,请重新输入\n");
break;
}
menuWab();
menu=getch();
}
if((fileWab=fopen("wab.dat","wb"))==NULL)
return 0;
while(startPtr!=NULL){
fwrite(startPtr,sizeof(DATAWAB),1,fileWab);
startPtr=startPtr->nextPtr;
}
puts("\n\n\t\t谢谢使用个人通讯录1.0,再见\n");
}
void menuWab(void) /*菜单函数*/
{
puts("\t\t\t主菜单");
puts("**********************************************************");
puts("**********************************************************");
puts("**\t<<-1->>所有记录\t\t<<-2->>查找记录\t\t**");
puts("**\t<<-3->>增加记录\t\t<<-4->>删除记录\t\t**");
puts("**\t<<-5->>修改记录\t\t<<-6->>退出程序\t\t**");
puts("**********************************************************");
puts("**********************************************************");
puts("\n请选择 1-6");
printf("#>");
}
void insertWab(DATAWABPTR *tempPtr,char temp2Name[],char temp2Telephone[],
char temp2Mobile[],char temp2Address[],char temp2Unit[])
/*插入函数*/
{
DATAWABPTR newPtr;
newPtr=(DATAWABPTR)malloc(sizeof(DATAWAB));
strcpy(newPtr->name,temp2Name);
strcpy(newPtr->telephone,temp2Telephone);
strcpy(newPtr->mobile,temp2Mobile);
strcpy(newPtr->address,temp2Address);
strcpy(newPtr->unit,temp2Unit);
newPtr->nextPtr=*tempPtr;
*tempPtr=newPtr;
}
void printWab(DATAWABPTR printPtr) /*打印函数*/
{
if(!(test(printPtr))){
printf("\n%8s%16s%16s%16s%16s\n","姓名","电话","手机","住址","单位");
while(printPtr!=NULL){
printf("%8s%16s%16s%16s%16s\n",printPtr->name,printPtr->telephone,
printPtr->mobile,printPtr->address,printPtr->unit);
printPtr=printPtr->nextPtr;
}
}
}
void seekWab(DATAWABPTR seekPtr,char tempName[])
/*查找函数*/
{
if(!(test(seekPtr))){
while(seekPtr!=NULL){
if(!(strcmp(tempName,seekPtr->name))){
printone(seekPtr);
seekPtr=seekPtr->nextPtr;
}
else
seekPtr=seekPtr->nextPtr;
}
}
}
void deleteWab(DATAWABPTR deletePtr,char deleteName[])
/*删除函数*/
{
DATAWABPTR tempPtr,forePtr;
forePtr=deletePtr;
tempPtr=deletePtr->nextPtr;
while(tempPtr!=NULL){
if(!(strcmp(tempPtr->name,deleteName))){
forePtr->nextPtr=tempPtr->nextPtr;
free(tempPtr);
break;
}
else{
forePtr=tempPtr;
tempPtr=tempPtr->nextPtr;
}
}
}
void modifyWab(DATAWABPTR modifyPtr,char modifyName[])
/*修改函数*/
{
if(!(test(modifyPtr))){
while(modifyPtr!=NULL){
if(!(strcmp(modifyName,modifyPtr->name))){
printf("请输入新姓名:");
scanf("%s",modifyPtr->name);
printf("\n请输入新电话:");
scanf("%s",modifyPtr->telephone);
printf("\n请输入新手机:");
scanf("%s",modifyPtr->mobile);
printf("\n请输入新地址:");
scanf("%s",modifyPtr->address);
printf("\n请输入新单位:");
scanf("%s",modifyPtr->unit);
break;
}
else
modifyPtr=modifyPtr->nextPtr;
}
}
}
int test(DATAWABPTR testPtr)
{
if(testPtr==NULL)
puts("通讯录内没有任何记录");
else
return 0;
return 1;
}
void printone(DATAWABPTR printone)
{
printf("\n%8s%16s%16s%16s%16s\n","姓名","电话","手机","住址","单位");
printf("%8s",printone->name);
printf("%16s",printone->telephone);
printf("%16s",printone->mobile);
printf("%16s",printone->address);
printf("%16s\n",printone->unit);
}
int controlWab(void)
{
puts("继续执行请按 1");
if(getch()=='1')
return 1;
return 0;
}
回答者: 虑而后能得 - 助理 二级 2-19 11:36
我来评论>>
提问者对于答案的评价:感激不尽~~评价已经被关闭 目前有 1 个人评价
好
100% (1) 不好
0% (0)
相关内容
• 救命啊! 哪位高手能帮我用C语言编写一个通讯录管理的...
• 3110c 通讯录的问题
• 索爱510c的电话本备份?
• 6120C的电话本能不能通过什么方式转到6500C来
• 关于诺基亚7310c通讯录显示姓名的问题~~~
更多关于c语言编写通讯录管理程序的问题>>
查看同主题问题:高手 语言 通讯录 救命 管理 程序
其他回答 共 4 条
分少啊,没动力,谁会写啊
回答者: 229273121 - 见习魔法师 三级 2-19 10:16
本人的C++通讯录程序代码
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<fstream>
#include<algorithm>
#define SPACE "\t\t\t"
using namespace std;
struct Record{
string name;
string tel;
public:
friend ostream& operator<<(ostream& os,const Record *rec){
return os<<rec->name<<SPACE<<rec->tel<<endl;
};
friend istream& operator>>(istream& is,Record *rec){
is>>rec->name;
is>>rec->tel;
return is;
}
static bool comp(string patten,int type,Record *rec){
switch(type){
case 0: {return rec->name==patten;}break;
case 1: {return rec->tel==patten;}break;
}
return false;
}
static bool isvan(Record *rec){
return (rec->name==""&&rec->tel=="");
}
};
class RecordList:public list<Record*>
{
public:
friend ostream& operator<<(ostream& os,const RecordList &c_rl){
RecordList::const_iterator it=c_rl.begin();
while(it!=c_rl.end()){
os<<*it;
it++;
}
return os;
}
friend istream& operator>>(istream& is,RecordList &rl){
RecordList::const_iterator it;
while(!is.eof()){
Record *prec=new Record;
is>>prec;
if(Record::isvan(prec)) continue;
rl.list<Record*>::push_back(prec);
}
return is;
}
void clear();
iterator erase(iterator pos);
~RecordList(){
this->clear();
}
};
void RecordList::clear(){
RecordList::const_iterator it=this->begin();
while(it!=this->end()){
delete(*it);
it++;
}
this->list<Record*>::clear();
}
RecordList::iterator RecordList::erase(iterator pos){
delete(*pos);
return list<Record*>::erase(pos);
}
class AddressList{
protected:
RecordList recList;
public:
typedef RecordList::iterator Iterator;
//从通信录中寻找一个记录
virtual Iterator findRecord(string patten,int type,Iterator from);
virtual void addRecord(Record* rec);
virtual void removeRecord(Iterator it);
virtual void editRecord(Record* rec,Iterator it);
virtual void saveRecords(ostream& os);
virtual void loadRecords(istream& is);
virtual void addRecords(istream& is);
virtual ~AddressList();
const int size() const{return (int)recList.size();}
const void clear(){recList.clear();}
Iterator begin(){return recList.begin();}
Iterator end() {return recList.end();}
};
AddressList::Iterator AddressList::findRecord(string patten,int type,Iterator from){
Iterator it;
it=from;
while(it!=recList.end()){
if(Record::comp(patten,type,*it)){
return it;
}
it++;
}
return it;
}
void AddressList::addRecord(Record* rec){
recList.push_back(rec);
}
void AddressList::removeRecord(Iterator it){
recList.erase(it);
}
void AddressList::editRecord(Record* rec,Iterator it){
delete(*it);
*it=rec;
}
void AddressList::saveRecords(ostream& os){
os<<recList;
}
void AddressList::loadRecords(istream& is){
is>>recList;
}
void AddressList::addRecords(istream& is){
}
AddressList::~AddressList(){
recList.clear();
}
class AddressBook : public AddressList{
protected:
bool isModified;//通信录是否已被修改还未保存
public:
AddressBook();
virtual ~AddressBook();
//开始通信录的用户界面操作
virtual void start();
//菜单处理函数管理程序的用户界面操作
virtual void handleMenu();
//显示记录
virtual void displayRecords();
//查询记录
virtual void queryRecord();
//添加记录
virtual void addRecord();
//保存记录
virtual void saveRecords();
//读取记录
virtual void loadRecords();
//结束程序
virtual void quit();
//清空当前记录信息
virtual void clear();
protected:
//菜单选择函数
char menuSelect();
//显示表头
void dispTable();
};
AddressBook::AddressBook(){
}
AddressBook::~AddressBook(){;}
char AddressBook::menuSelect(){
char a=0;
cin>>a;
if(a=='y'||a=='Y'){a='1';}
if(a=='n'||a=='N'){a='2';}
return a;
}
void AddressBook::start(){
cout << "\n\t***** 欢迎使用通讯录管理程序 *****";
handleMenu();
}
void AddressBook::handleMenu(){
cout << "\n\n\t\t\t-- 菜单管理 --\n\n";
cout << "\tA -- 添加人员纪录 (Add Record)\n"
<< "\tF -- 查询纪录 (Find Record)\n"
<< "\tD -- 显示纪录 (Display Records)\n"
<< "\tL -- 从文本或标准输入流中加载纪录 (Load Records)\n"
<< "\tC -- 清空当前记录信息\n"
<< "\tS -- 保存记录 (Save Records)\n"
<< "\tQ -- 结束程序 (QUIT)\n";
switch(menuSelect()){
case 'A':
case 'a':addRecord();break;
case 'F':
case 'f':queryRecord();break;
case 'D':
case 'd':displayRecords();break;
case 'L':
case 'l':loadRecords();break;
case 'C':
case 'c':clear();break;
case 'S':
case 's':saveRecords();break;
case 'Q':
case 'q':quit();break;
}
handleMenu();
}
void AddressBook::displayRecords(){
cout<<"姓名"<<SPACE<<"电话"<<endl;
AddressList::saveRecords(cout);
cout<<"一共找到"<<size()<<"个对象。"<<endl;
cout<<"1"<<SPACE<<"返回"<<endl;
cout<<"2"<<SPACE<<"修改"<<endl;
cout<<"3"<<SPACE<<"删除"<<endl;
switch(menuSelect()){
case '1':break;
case '2':{
if(!size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要修改第几个?"<<"1~"<<size()<<endl;
int i;
cin>>i;
if(i<1||i>size()){
break;
}
Record *prec=new Record;
cout<<"姓名:"<<'\n'<<"电话:"<<'\n';
cin>>prec;
Iterator it=recList.begin();
while(i!=1){
it++;
i--;
}
editRecord(prec,it);
}break;
case'3':{
if(!size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要删除第几个?"<<"1~"<<size()<<endl;
int i;
cin>>i;
if(i<1||i>size()){
break;
}
Iterator it=recList.begin();
while(i!=1){
it++;
i--;
}
removeRecord(it);
}break;
}
}
void AddressBook::addRecord(){
string name,tel;
cout << "\n输入名字: ";
cin >> name;
cout << "输入电话: ";
cin >> tel;
Record* temp=new Record;
temp->name=name;
temp->tel=tel;
AddressList::addRecord(temp);
cout<<"是否继续(Y/N)"<<endl;
switch(menuSelect()){
case '1':addRecord();break;
case '2':break;
}
}
void AddressBook::queryRecord(){
cout<<"1"<<SPACE<<"按姓名查找"<<endl;
cout<<"2"<<SPACE<<"按电话查找"<<endl;
int type=-1;
string patten;
switch(menuSelect()){
case '1':{
type=0;
cout<<"请输入姓名"<<endl;
cin>>patten;
}break;
case '2':{
type=1;
cout<<"请输入电话号码"<<endl;
cin>>patten;
}break;
}
Iterator it=begin();
list<Iterator> li;
cout<<"姓名"<<SPACE<<"电话"<<endl;
while((it=findRecord(patten,type,it))!=end()){
cout<<*it;
li.push_back(it);
it++;
}
cout<<"一共找到"<<li.size()<<"个对象。"<<endl;
cout<<"1"<<SPACE<<"返回"<<endl;
cout<<"2"<<SPACE<<"修改"<<endl;
cout<<"3"<<SPACE<<"删除"<<endl;
switch(menuSelect()){
case'1':break;
case'2':{
if(!li.size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要修改第几个?"<<"1~"<<li.size()<<endl;
int i;
cin>>i;
Record *prec=new Record;
cout<<"姓名:"<<'\n'<<"电话:"<<'\n';
cin>>prec;
list<Iterator>::const_iterator it=li.begin();
while(i!=1){
it++;
i--;
}
editRecord(prec,*it);
}break;
case'3':{
if(!li.size()){
cout<<"记录为0,无法修改。"<<endl;
break;
}
cout<<"要删除第几个?"<<"1~"<<li.size()<<endl;
int i;
cin>>i;
list<Iterator>::const_iterator it=li.begin();
while(i!=1){
it++;
i--;
}
removeRecord(*it);
}break;
}
}
void AddressBook::saveRecords(){
cout<<"1"<<SPACE<<"使用默认文件名。"<<endl;
cout<<"2"<<SPACE<<"使用自定义文件名。"<<endl;
cout<<"3"<<SPACE<<"返回"<<endl;
switch(menuSelect()){
case '1':{
ofstream file("default",ios::app);
AddressList::saveRecords(file);
file.close();
}break;
case '2':{
cout<<"请输入您定义的文件名:"<<endl;
string fname;
cin>>fname;
ofstream file(fname.c_str(),ios::app);
AddressList::saveRecords(file);
file.close();
}break;
case '3':break;
}
}
void AddressBook::loadRecords(){
cout<<"1"<<SPACE<<"使用默认文件。"<<endl;
cout<<"2"<<SPACE<<"使用自定义文件。"<<endl;
cout<<"3"<<SPACE<<"返回"<<endl;
switch(menuSelect()){
case '1':{
cout<<"1"<<SPACE<<"覆盖当前内容"<<endl;
cout<<"2"<<SPACE<<"追加到当前文件"<<endl;
switch(menuSelect()){
case '1':
AddressList::clear();break;
case '2':break;
}
ifstream file("default");
AddressList::loadRecords(file);
file.close();
}break;
case '2':{
cout<<"请输入文件名:"<<endl;
string fname;
cin>>fname;
ifstream file(fname.c_str());
AddressList::loadRecords(file);
file.close();
}break;
case '3':break;
}
}
void AddressBook::clear(){
cout<<"是否要清除内存中所有内容?(Y/N)"<<endl;
switch(menuSelect()){
case '1':AddressList::clear();break;
case '2':break;
}
}
void AddressBook::quit(){
cout<<"是否要保存文件?(Y/N)"<<endl;
switch(menuSelect()){
case'1':saveRecords();break;
case'2':break;
}
exit(0);
}
int main(int argc, char *argv[])
{
AddressBook a;
a.start();
system("PAUSE");
return EXIT_SUCCESS;
}
展开全部
这个是我大一的时候做的
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "conio.h"
struct person
{
char name[10];
char tel[15];
char addr[50];
};
char filename[20];
FILE *fp;
void creat();
void output();
void search();
void append();
void modify();
void del();
void menu()
{
printf("\n\t\t******************通讯录*****************");
printf("\n\t\t* *");
printf("\n\t\t* 添加,请按1 *");
printf("\n\t\t* 查找,请按2 *");
printf("\n\t\t* 修改,请按3 *");
printf("\n\t\t* 删除,请按4 *");
printf("\n\t\t* 输出,请按5 *");
printf("\n\t\t* 退出,请按0 *");
printf("\n\t\t*****************************************");
}
void main()
{
int m;
creat();
system("cls");
while(1)
{
menu();
printf("\n请选择:");
scanf("%d",&m);
if(m>=0&&m<=5)
{
switch(m)
{
case 1: append();
break;
case 2: search();
break;
case 3: modify();
break;
case 4: del();
break;
case 5: output();
break;
case 0: exit(1);
}
printf("\n\n操作完毕,请在次选择!");
}
else
printf("\n\n选择错误,请在次选择!");
}
}
void creat()
{
system("cls");
struct person one;
printf("\n请输入通讯录名:");
scanf("%s",filename);
if((fp=fopen(filename,"w"))==NULL)
{
printf("\n不能建立通讯录!");
exit(1);
}
fprintf(fp,"%-10s%-20s%-50s\n","姓名","电话号码","住址");
printf("\n请输入姓名、电话号码及住址(以0结束)\n");
scanf("%s",one.name);
while(strcmp(one.name,"0"))
{
scanf("%s%s",one.tel,one.addr);
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
scanf("%s",one.name);
}
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
void output()
{
system("cls");
struct person one;
if((fp=fopen(filename,"r"))==NULL)
{
printf("\n不能建立通讯录!");
exit(1);
}
printf("\n\n%20s\n","通 讯 录");
while(!feof(fp))
{
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
printf("%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
}
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
void append()
{
system("cls");
struct person one;
if((fp=fopen(filename,"a"))==NULL)
{
printf("\n不能建立通讯录!");
exit(1);
}
printf("\n请输入添加的姓名、电话号码及住址\n");
scanf("%s%s%s",one.name,one.tel,one.addr);
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
void search()
{
system("cls");
int k=0;
char namekey[10];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"rb"))==NULL)
{
printf("\n不能打开通讯录!");
exit(1);
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
printf("\n\n已查到,记录为:");
printf("%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
k=1;
}
}
if(!k)
printf("\n\n对不起,通讯录中没有此人的记录.");
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
void modify()
{
system("cls");
int m=0,k=0;
long offset;
char namekey[10];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"r+"))==NULL)
{
printf("\n不能打开通讯录!");
exit(1);
}
while(!feof(fp))
{
offset=ftell(fp);
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
k=1;
break;
}
}
if(k)
{
printf("\n已查到,记录为:");
printf("%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
printf("\n请输入新姓名、电话号码及住址:");
scanf("%s%s%s",one.name,one.tel,one.addr);
fseek(fp,offset,SEEK_SET);
printf("%ld",ftell(fp));
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
}
else
printf("\n对不起,通讯录中没有此人的记录.");
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
void del()
{
system("cls");
int m,k=0,flag;
long offset1,offset2;
char namekey[10],valid[4];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"r+"))==NULL)
{
printf("\n不能打开通讯录!");
exit(1);
}
while(!feof(fp))
{
offset1=ftell(fp);
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
k=1;
break;
}
}
if(k)
{
printf("\n已查到,记录为:");
printf("%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
printf("\n确实要删除,按1; 不删除,按0:");
scanf("%d",&m);
if(m)
{
fseek(fp,offset1,SEEK_SET);
fprintf(fp,"%-10s%-20s%-50s\n"," "," "," ");
}
}
else
printf("\n对不起,通讯录中没有此人的记录.");
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "conio.h"
struct person
{
char name[10];
char tel[15];
char addr[50];
};
char filename[20];
FILE *fp;
void creat();
void output();
void search();
void append();
void modify();
void del();
void menu()
{
printf("\n\t\t******************通讯录*****************");
printf("\n\t\t* *");
printf("\n\t\t* 添加,请按1 *");
printf("\n\t\t* 查找,请按2 *");
printf("\n\t\t* 修改,请按3 *");
printf("\n\t\t* 删除,请按4 *");
printf("\n\t\t* 输出,请按5 *");
printf("\n\t\t* 退出,请按0 *");
printf("\n\t\t*****************************************");
}
void main()
{
int m;
creat();
system("cls");
while(1)
{
menu();
printf("\n请选择:");
scanf("%d",&m);
if(m>=0&&m<=5)
{
switch(m)
{
case 1: append();
break;
case 2: search();
break;
case 3: modify();
break;
case 4: del();
break;
case 5: output();
break;
case 0: exit(1);
}
printf("\n\n操作完毕,请在次选择!");
}
else
printf("\n\n选择错误,请在次选择!");
}
}
void creat()
{
system("cls");
struct person one;
printf("\n请输入通讯录名:");
scanf("%s",filename);
if((fp=fopen(filename,"w"))==NULL)
{
printf("\n不能建立通讯录!");
exit(1);
}
fprintf(fp,"%-10s%-20s%-50s\n","姓名","电话号码","住址");
printf("\n请输入姓名、电话号码及住址(以0结束)\n");
scanf("%s",one.name);
while(strcmp(one.name,"0"))
{
scanf("%s%s",one.tel,one.addr);
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
scanf("%s",one.name);
}
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
void output()
{
system("cls");
struct person one;
if((fp=fopen(filename,"r"))==NULL)
{
printf("\n不能建立通讯录!");
exit(1);
}
printf("\n\n%20s\n","通 讯 录");
while(!feof(fp))
{
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
printf("%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
}
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
void append()
{
system("cls");
struct person one;
if((fp=fopen(filename,"a"))==NULL)
{
printf("\n不能建立通讯录!");
exit(1);
}
printf("\n请输入添加的姓名、电话号码及住址\n");
scanf("%s%s%s",one.name,one.tel,one.addr);
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
void search()
{
system("cls");
int k=0;
char namekey[10];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"rb"))==NULL)
{
printf("\n不能打开通讯录!");
exit(1);
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
printf("\n\n已查到,记录为:");
printf("%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
k=1;
}
}
if(!k)
printf("\n\n对不起,通讯录中没有此人的记录.");
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
void modify()
{
system("cls");
int m=0,k=0;
long offset;
char namekey[10];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"r+"))==NULL)
{
printf("\n不能打开通讯录!");
exit(1);
}
while(!feof(fp))
{
offset=ftell(fp);
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
k=1;
break;
}
}
if(k)
{
printf("\n已查到,记录为:");
printf("%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
printf("\n请输入新姓名、电话号码及住址:");
scanf("%s%s%s",one.name,one.tel,one.addr);
fseek(fp,offset,SEEK_SET);
printf("%ld",ftell(fp));
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
}
else
printf("\n对不起,通讯录中没有此人的记录.");
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
void del()
{
system("cls");
int m,k=0,flag;
long offset1,offset2;
char namekey[10],valid[4];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"r+"))==NULL)
{
printf("\n不能打开通讯录!");
exit(1);
}
while(!feof(fp))
{
offset1=ftell(fp);
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
k=1;
break;
}
}
if(k)
{
printf("\n已查到,记录为:");
printf("%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
printf("\n确实要删除,按1; 不删除,按0:");
scanf("%d",&m);
if(m)
{
fseek(fp,offset1,SEEK_SET);
fprintf(fp,"%-10s%-20s%-50s\n"," "," "," ");
}
}
else
printf("\n对不起,通讯录中没有此人的记录.");
fclose(fp);
printf("按任意键继续......");
getch();
system("cls");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我们的结业设计就是这个
很麻烦
但是处理好的话不难~
很麻烦
但是处理好的话不难~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询