标题:文件怎么打不开呢?
取消只看楼主
兔彤
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-388928-1-1.html




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

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