| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 321 人关注过本帖
标题:文件怎么打不开呢?
取消只看楼主 加入收藏
兔彤
Rank: 1
来 自:北京
等 级:新手上路
帖 子:15
专家分:0
注 册:2012-11-20
结帖率:44.44%
收藏
已结贴  问题点数:10 回复次数:0 
文件怎么打不开呢?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"dazuoye.h"
void readFile()
{
    int n;
    struct stuMessage *head ,*temp;
    FILE *inFile;

   
    inFile = fopen("stuImformation.txt","r");
   
    if(inFile == NULL)
    {
        printf("文件打开失败,请检查文件是否存在");
        exit(1);
    }
    else
    {
        while(fscanf(inFile,"%s %s %s\n",head->name,head->idnum,head->Clanum)!=EOF)
        {
            head->nextaddr = NULL;

            if(firstaddr==NULL)
            {
                firstaddr=head;
                temp=head;
            }
            else
            {
                temp->nextaddr=head;
                temp=head;
            }
            head=(struct stuMessage *)malloc(sizeof(struct stuMessage *));
        }
    }
   
    fclose(inFile);
}
void saveFile()
{
    struct stuMessage *temp;
    FILE *outFile;
    int n;
    outFile=fopen("stuImformation.txt","w");

    if(outFile==NULL)
    {
        printf("文件打开失败!");
        exit(1);
    }

    while(firstaddr!=NULL)
    {
        temp=firstaddr;
        firstaddr=firstaddr->nextaddr;
        fprintf(outFile,"%s %s %s",temp->name,temp->idnum,temp->Clanum);
        for(n=0;n<10;n++)
        {
            fprintf(outFile,"%f",temp->grade[n]);
            free(temp);
        }
        fprintf(outFile,"\n",0);
    }
    fclose(outFile);
}
搜索更多相关主题的帖子: void 检查 include 
2012-11-29 06:19
快速回复:文件怎么打不开呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017886 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved