| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1011 人关注过本帖
标题:读取文件输出乱码问题
取消只看楼主 加入收藏
a3575181
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2016-12-13
结帖率:80%
收藏
已结贴  问题点数:18 回复次数:1 
读取文件输出乱码问题
已经写入了一个student.dat文件,下面代码就是读取输出,但是输出乱码了。
写入文件为
Student stus[3]={{"teacher","tea123","0"},{"student","stu123","0"},{"fdy","fdy123","1"}};

图片附件: 游客没有浏览图片的权限,请 登录注册

程序代码:
#include <stdio.h>
#include <stdlib.h>
#include"conio.h"
#include"string.h"
#include"windows.h"
typedef
struct{
char name[20];
char ps[10];
char power[10];
}Student;


int main(){

printf("数组temp的内容为:\n");
     int i;
     Student show[3];
    int size=sizeof(Student);
    FILE *fp=fopen("student.dat","rb");
    if(fp==NULL){
        printf("文件%s打不开\n","student");
        }
    else if(fp!=NULL){
        for(i=0;i<3;i++){
            int count=fread(show,size,1,fp);
            if(count==1){
                show[i]=*show;


            }
        }
        fclose(fp);
    }
printf("%s%s%s\n",show[1].name,show[2].name,show[3].name);

}




[此贴子已经被作者于2016-12-25 19:12编辑过]

搜索更多相关主题的帖子: color 
2016-12-25 19:10
a3575181
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2016-12-13
收藏
得分:0 
回复 2楼 九转星河
报错!

note: expected 'void *' but argument is of type 'Student'|
2016-12-25 20:00
快速回复:读取文件输出乱码问题
数据加载中...
 
   



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

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