| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 654 人关注过本帖
标题:C语言读写文件的问题
取消只看楼主 加入收藏
zuojian168
Rank: 2
等 级:论坛游民
帖 子:16
专家分:27
注 册:2013-3-20
结帖率:100%
收藏
已结贴  问题点数:15 回复次数:0 
C语言读写文件的问题
#include<stdio.h>
struct STUDENT
{
    int num;
    char name[20];
    char sex[10];
    char address[30];
    int phone;
}Student[3];
 int main()
{    FILE *fp;
    int i;
    printf("请输入学号,姓名,性别,地址,电话:\n");
    for(i = 0;i < 3;i++)
    {
        scanf("%d%s%s%s%d",&Student[i].num,Student[i].name,Student[i].sex,Student[i].address,&Student[i].phone);
        printf("\n");
    }
   
    fp = fopen("student.txt","w");
    fwrite(&Student,sizeof(struct STUDENT),3,fp);
    return 0;
}
我想输入3名同学的信息,写入student.txt文件中,为什么打开student.txt会有乱码?
搜索更多相关主题的帖子: address include C语言 电话 姓名 
2013-10-09 15:09
快速回复:C语言读写文件的问题
数据加载中...
 
   



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

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