当前位置:网站首页>Console program for viewing BMP files
Console program for viewing BMP files
2022-06-11 07:12:00 【lihongtao8209】
1.DEV 5.0
Program usage DEV 5.0 Development . But because the author's operating system is Chinese , So use printf Print more than ASCII code 128 I will appear Chinese garbled code . This is because two are greater than 128 Of ASCII Of WINDOWS In the Chinese system, it is changed to by default GB2312 Chinese characters of . The solution is , Open console , Turn the current environment into English .
-----------------------------------------------------------------------------
Console command |Windows Console code page code | meaning |
-----------------------------------------------------------------------------
chcp |437 | American English |
------------------------------------------------------------------------------
chcp |936 | chinese GBK |
-------------------------------------------------------------------------------
chcp The order is : chcp code page .
2.WIN TC
Later, the operating system was reinstalled , stay 64M Move U Found it on the disk WINTC This compiler . compile 、 Run it ,OK. No need to change the code page .
3.DEV 5.0 Code
/*
---------------------------------------------
Console command |Windows Console code page code | meaning |
----------------------------------------------
chcp |437 | American English |
----------------------------------------------
chcp |936 | chinese GBK |
----------------------------------------------
*/
#include <stdio.h>
#include <string.h>
#define INFO_LEN 17
int main(int argc, char** argv) {
int ch=0;
int index=0;
int row=0;
char chs[INFO_LEN];
FILE *fp=NULL;
memset((void*)chs,0,INFO_LEN);
fp=fopen("1.bmp","rb");
if(fp==NULL)
{
printf("not exist file.\n");
return -1;
}
if(index==0)
{
printf("%3s"," ");
for(int i=0;i<16;i++)
{
printf("%02X ",i);
}
printf("\n");
}
do{
ch=fgetc(fp);
if(index%16==0 )
{
if(index!=0)
{
//printf(" %s\n",chs);
printf(" ");
for(int i=0;i<16;i++)
putchar(chs[i]);
printf("\n");
}
printf("%02X ",row++);
memset((void*)chs,0,INFO_LEN);
}
printf("%02x ",ch);
//
if(ch>=32 &&ch <=254)
chs[index%16]=ch;
else if(ch>=1 && ch <=8)
chs[index%16]=ch;
else if(ch==9 || ch==10 || ch==13||ch==0)
chs[index%16]=152;
else if(ch>=14 && ch<=31)
chs[index%16]=ch;
else
chs[index%16]='.';
//
index++;
}while(!feof(fp));
fclose(fp);
return 0;
}
4.WIN TC Code
#include <stdio.h>
#include <string.h>
#define INFO_LEN 17
int main(int argc, char** argv) {
int i=0;
int ch=0;
int index=0;
int row=0;
char chs[INFO_LEN];
FILE *fp=NULL;
memset((void*)chs,0,INFO_LEN);
fp=fopen("1.bmp","rb");
if(fp==NULL)
{
printf("not exist file.\n");
getchar();
return -1;
}
if(index==0)
{
printf("%3s"," ");
for(i=0;i<16;i++)
{
printf("%02X ",i);
}
printf("\n");
}
do{
ch=fgetc(fp);
if(index%16==0 )
{
if(index!=0)
{
/*printf(" %s\n",chs);*/
printf(" ");
for( i=0;i<16;i++)
putchar(chs[i]);
printf("\n");
}
printf("%02X ",row++);
memset((void*)chs,0,INFO_LEN);
}
printf("%02x ",ch);
/*********************************/
if(ch>=32 &&ch <=254)
chs[index%16]=ch;
else if(ch>=1 && ch <=8)
chs[index%16]=ch;
else if(ch==9 || ch==10 || ch==13||ch==0)
chs[index%16]=152;
else if(ch>=14 && ch<=31)
chs[index%16]=ch;
else
chs[index%16]='.';
/*********************************/
index++;
}while(!feof(fp));
fclose(fp);
getch();
return 0;
}
边栏推荐
- Mybags puls will report an error invalid bound statement (not found) when writing an SQL statement in the XML file:
- Matplotlib, set coordinate scale size, font / set legend size and font / set vertical and horizontal coordinate name, font and size
- P3172 [cqoi2015] data selection (Mobius inversion + Du Jiao sieve)
- Luogu p1091 chorus formation (longest ascending subsequence)
- The difference between TCP and UDP
- Comparison of DOM tags of wechat applet development (native and uniapp)
- Graph Attention Tracking
- AtomicInteger原子操作类
- 正则表达式匹配
- 商汤科技积极复工,将大力投入数字哨兵的产能和部署
猜你喜欢

The difference between arrow function and ordinary function

saltstack部署lnmp

Xunwei dry goods | Ruixin micro rk3568 development board TFTP & NFS writing (Part 1)

1、 Sqlserver2008 installation (with password), database creation, C form project test

教育专家王中泽老师多年经验分享:家庭教育不是附庸品

Installation de SQL Server 2008 (avec mot de passe), création d'une base de données, test de projet de formulaire C

webserver

Leetcode-141. Linked List Cycle

. Net C Foundation (6): namespace - scope with name
![[matlab WSN communication] a_ Star improved leach multi hop transmission protocol [including source code phase 487]](/img/fd/53776b550390752282cd8797193436.png)
[matlab WSN communication] a_ Star improved leach multi hop transmission protocol [including source code phase 487]
随机推荐
河南高考VS天津高考(2008年-2021年)
Education expert wangzhongze shared his experience for many years: family education is not a vassal
农房一体脚本的心得记录
MS office level II wrong question record [4]
matplotlib的cmap
LEARNING TARGET-ORIENTED DUAL ATTENTION FOR ROBUST RGB-T TRACKING
WPF 数据绑定(四)
News web page display
421. maximum XOR value of two numbers in the array
教育专家王中泽老师多年经验分享:家庭教育不是附庸品
**Count the characters with the largest number of words**
Education expert Mr. wangzhongze: family education focuses on self growth
213. house raiding II
Common modules of saltstack
Experience record of rural housing integration script
Server parameter adjustment record
[MATLAB image fusion] particle swarm optimization adaptive multispectral image fusion [including source code phase 004]
.NET C#基础(6):命名空间 - 有名字的作用域
SQL query. Only the column name is displayed but not the data
Leetcode hot topic 100 topic 11-15 solution