Chinaunix首页 | 论坛 | 博客
  • 博客访问: 445558
  • 博文数量: 111
  • 博客积分: 4290
  • 博客等级: 上校
  • 技术积分: 1301
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-24 14:22
个人简介

努力工作,建立一个幸福的家庭。

文章分类

全部博文(111)

文章存档

2015年(4)

2013年(9)

2012年(6)

2011年(17)

2010年(69)

2009年(6)

分类: WINDOWS

2011-04-21 22:10:14

读取I1.txt中的数值
 

#include <stdio.h>
#include <string.h>

void main()
{
    int i = 0;
    char *buf;
    FILE *fp;
    fp = fopen("I1.txt","r");
    buf = (char*)malloc(1921);
    while(!feof(fp))
    {
        buf[i] = fgetc(fp);
        if (buf[i] == ','){
        }else{
            i++;
        }
    }
    fclose(fp);
    getchar();
}

I1.txt文件

1,1,1,1,1,1,0,0,0,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,0,0,0,1,1,1,1,0,1,0,1,0,1,0,1,1,1

,1,1,1,0,0,0,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,0,0,0,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,

1,0,0,0,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,0,0,0,1,1,1,1,0,1,0,1,0,1,0,1,0,0,1,1,1,1,0

,1,1,1,1,0,1,0,1,0,1,1,1,1,0,0,1,1,1,1,0,1,1,1,1,0,1,0,1,0,1,1,1,1,0,0,1,1,1,1,0,1,1,

1,1,0,1,0,1,0,1,1,1,1,0,0,1,1,1,1,0,1,1,1,1,0,1,0,1,0,1,1,1,1,0,0,1,1,1,1,0,1,1,1,1,0

,1,0,1,0,1,1,1,1,0,0,1,1,1,1,0,1,1,1,1,0,1,0,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,0,1,0,0,0,

0,0,1,0,1,1,1,1,1,1,0,1,1,0,1,0,1,0,0,0,0,0,1,0,1,1,1,1,1,1,0,1,1,0,1,0,1,0,0,0,0,0,1

,0,1,1,1,1,1,1,0,1,1,0,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

,1,0,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,0,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,0,0,1,0,

1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,0,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,0,0,1,0,1,1,0

,1,1,1,0,1,1,1,


2  读取科学计数中的数值

data_I_train_word_1_i0_256.txt

3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 -3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000


程序

 

#include <stdio.h>
#include <stdlib.h>

int main()
{
        float f[256];
        int i=0;
        FILE *fp=fopen( "data_I_train_word_1_i0_256.txt", "r ");
        
        while(!feof(fp))
        {
                fscanf(fp, "%f ", &f[i]); //%f 读取文件即可

                i++;
        }
        
        system( "pause ");
        return 0;
}


输出为float数。
阅读(3540) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~