鱼C论坛

 找回密码
 立即注册
查看: 1086|回复: 0

有人能帮忙调试一小段程序么,不知道哪里错了。

[复制链接]
发表于 2015-2-19 18:30:09 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

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;
}



想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-2-24 04:43

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表