标题:文件怎么打不开呢?
只看楼主
兔彤
Rank: 1
来 自:北京
等 级:新手上路
帖 子:15
专家分:0
注 册:2012-11-20
结帖率:44.44%
已结贴  问题点数:10 回复次数:2 
文件怎么打不开呢?
#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
heroinearth
Rank: 10Rank: 10Rank: 10
来 自:云南曲靖
等 级:青峰侠
帖 子:430
专家分:1506
注 册:2011-10-24
得分:5 
你好地检查文件名是否一样,信息是:information
2012-11-29 08:07
lxsjzbd
Rank: 4
来 自:河北省
等 级:业余侠客
帖 子:97
专家分:258
注 册:2012-3-31
得分:5 
看看你的txt文件是否和.c文件放一起了
2012-11-29 16:33



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




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

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