|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 阿土先生 于 2015-2-19 20:03 编辑
- <span style="line-height: 1.5; background-color: rgb(255, 255, 255);">txt中的内容是这样的:</span>
复制代码 编号 姓名 性别 生日 电话1 电话2 电话3 所在地 分组
001 李勇 男 1991 18912345678 15398745612 68891234 湖北武汉 1
002 刘晨 女 1992-04-01 15301391234 北京 2
003 王敏 女 1980 13838197777 18603712222 河南郑州 3
005 张立 男 15612346598 呼和浩特 2
006 小四川 18088888888 87878777 武汉 6
- #include<cstdio>
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- #define TRUE 1
- #define FALSE 0
- #define OK 1
- #define ERROR 0
- #define INFEASIBLE -1
- #define OVERFLOW -2
- #define flag -1
- #define filename_1 "Friend.txt"
- #define filename_2 "Group.txt"
- typedef int Status;
- typedef struct Contact{
- char number[10];
- char name[10];
- char sex[5];
- char tel_1[20];
- char tel_2[20];
- char tel_3[20];
- char address[256];
- char group_num[10];
- struct Contact *next;
- }LNode,*LinkList;
- Status Copy(LinkList &L,FILE *fp1,char str[]){
- if(!(fp1 = fopen(filename_1, "r+"))){
- cout<<"Cannot open the file!"<<endl;
- exit(0);
- }
- if(!(L = (LinkList)malloc(sizeof(LNode)))){
- cout<<"内存空间不足,该删两部片了!"<<endl;
- exit(0);
- }
- L->next = NULL;
- LinkList p=L->next;
- freopen(filename_1,"r",stdin);
- gets(str);
- while(scanf("%9s%9s%9s%11s%12s%12s%12s%11s%5s",&p->number,&p->name,&p->sex,&p->tel_1,&p->tel_2,&p->tel_3,&p->address,&p->group_num))
- p=p->next;
- p=NULL;
- freopen("CON","r",stdin);
- fclose(fp1);
- return OK;
- }
- int main(){
- FILE *fri,*gro;
- char firstline[100];
- LinkList L;
- Copy(L,fri,firstline);
- printf("%s",firstline);
- return OK;
- }
复制代码
|
|