| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1089 人关注过本帖
标题:读取16进制的文件然后显示出来~请进指教
只看楼主 加入收藏
nexus88
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-1-5
收藏
 问题点数:0 回复次数:3 
读取16进制的文件然后显示出来~请进指教
有个AAA。BIN 里面是用16进制编写的文件
请问如何用VC++或者C来打开文件 并且让它显示在屏幕上 然后我要编辑它
搜索更多相关主题的帖子: 进制 文件 指教 
2007-01-07 00:05
pinglideyu
Rank: 3Rank: 3
来 自:武汉工程大学
等 级:论坛游侠
威 望:1
帖 子:735
专家分:140
注 册:2007-1-7
收藏
得分:0 

这个行不?
#include <fstream.h>
#include <iostream.h>
#include <stdlib.h>
#include <iomanip.h>

void textread()
{
char ch;
ifstream readchar;
readchar.open("text1.dat");
if (!readchar)
{
cout<<"Error!Cannot open file!"<<endl;
exit(1);
}
while (readchar.get(ch))
cout.put(ch);
cout<<endl;
}
void main()
{
textread();
}


~~我的明天我知道~~
2007-01-07 11:19
nexus88
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-1-5
收藏
得分:0 
不行哦 你没有转换16进 它是16进的文件 举2行例子给你们看
000000 58 00 00 00 59 03 C9 01 59 03 X...Y...Y...
000010 65 01 97 10 01 FF C9 10 97 01 e...e.e.....

是这样的
2007-01-07 13:13
shenql
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-4-16
收藏
得分:0 
#include<stdio.h>
#include<stdlib.h>
int print_bit(int i);
int main()
{
    FILE *infile,*outfile;
    int ch[50];
    char filename[20]="D:/test/test3.eti";
    int num1,i=0;
//    long num2;
    //double num3;

    infile = fopen(filename,"rb");
    outfile=fopen("D:/test.dat","wb");
    if (infile==NULL)
    {
        printf("\n The file %s was not successfullly opened!",filename);
        printf("\n Please check that the file currently exists.\n");
        exit(1);
    }

    fread(&num1,sizeof(num1),1,infile);
    
    //fread(&num2,sizeof(num2),1,infile);
    //fread(&num3,sizeof(num3),1,infile);

    fclose(infile);
    printf("The data input from the %s file is:",filename);
    printf("%x %d \n",num1,sizeof(filename[0]));
    
    //print_bit(num1);
    
    for(i=0;i<=49;i++)
        fwrite(&ch[i],sizeof(ch[i]),1,outfile);
    fclose(outfile);
    return 0;
}
2008-04-16 21:34
快速回复:读取16进制的文件然后显示出来~请进指教
数据加载中...
 
   



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

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