| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 647 人关注过本帖
标题:各位高手帮看一下哪错了,谢谢
只看楼主 加入收藏
呵呵呵。。
Rank: 2
等 级:论坛游民
帖 子:43
专家分:52
注 册:2010-6-11
结帖率:88.89%
收藏
已结贴  问题点数:20 回复次数:6 
各位高手帮看一下哪错了,谢谢
#include <stdio.h>
#include <stdlib.h>
void main()
{
    int i=3;
    float f=6.2;
   
    FILE *fp;

    if((fp=fopen("wang.txt","w"))==NULL)
    {
        printf("can't create file: wang.txt\n");
        exit(0);
    }
    fprintf(fp,"%2d,%6.2f",i,f);
    fclose(fp);

    if((fp=fopen("wang.txt","r"))==NULL)
    {
        printf("can't openfile:wang.txt\n");
        exit(0);

    }
    i=0;f=0;
    fcanf(fp,"%2d,%6.2f",&i,&f);
    fclose(fp);

    printf("i=%2d,f=%6f\n",i,f);
}
搜索更多相关主题的帖子: void include create file 
2011-01-14 18:45
广陵绝唱
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:29
帖 子:3607
专家分:1709
注 册:2008-2-15
收藏
得分:3 
fscanf 写错了.
2011-01-14 19:15
A13433758072
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:广东潮州
等 级:小飞侠
威 望:1
帖 子:1182
专家分:2784
注 册:2010-7-22
收藏
得分:3 


 fcanf(fp,"%2d,%6.2f",&i,&f);   这个是什么输入吗????有规定输入
精度

一步一个脚印...............................默默地前进.....
诚邀乐于解答c菜鸟问题,的热心网友加入,  QQ群38490319
2011-01-14 22:13
sunmingchun
Rank: 4
来 自:安徽-滁州
等 级:业余侠客
帖 子:198
专家分:277
注 册:2010-4-2
收藏
得分:3 
#include <stdio.h>
#include <stdlib.h>
void main()
{
    int i=3;
    float f=6.2;
   
    FILE *fp;

    if((fp=fopen("wang.txt","w"))==NULL)
    {
        printf("can't create file: wang.txt\n");
        exit(0);
    }
    fprintf(fp,"%2d,%6f",i,f);
    fclose(fp);

    if((fp=fopen("wang.txt","r"))==NULL)
    {
        printf("can't openfile:wang.txt\n");
        exit(0);

    }
    i=0;f=0;
    fscanf(fp,"%2d,%6f",&i,&f);
    fclose(fp);

    printf("i=%2d,f=%.2f\n",i,f);
}

2011-01-15 10:34
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
收藏
得分:3 
#include <stdio.h>
#include <stdlib.h>
void main()
{
    int i=3;
    float f=6.2;
   
    FILE *fp;

    if((fp=fopen("wang.txt","w"))==NULL)
    {
        printf("can't create file: wang.txt\n");
        exit(0);
    }
    fprintf(fp,"%2d %6.2f",i,f);
    fclose(fp);

    if((fp=fopen("wang.txt","r"))==NULL)
    {
        printf("can't openfile:wang.txt\n");
        exit(0);

    }
    i=0;f=0;
    fcanf(fp,"%2d %6.2f",&i,&f);
    fclose(fp);

    printf("i=%2d,f=%.2\n",i,f);
}


[ 本帖最后由 qq1023569223 于 2011-1-15 13:10 编辑 ]

   唯实惟新 至诚致志
2011-01-15 12:55
xdzsm
Rank: 2
等 级:论坛游民
帖 子:137
专家分:99
注 册:2010-10-26
收藏
得分:3 
4#正解
2011-01-15 20:49
麦田打望者
Rank: 2
等 级:论坛游民
帖 子:62
专家分:34
注 册:2010-5-31
收藏
得分:3 
支持
2011-01-15 23:07
快速回复:各位高手帮看一下哪错了,谢谢
数据加载中...
 
   



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

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