#include <stdio.h>
void PrintHexaNAscii(const unsigned char *buffer, int size);
int main()
{
int a = 0xffffffff;
PrintHexaNAscii((unsigned char *)&a, 100);
return 0;
}
void PrintHexaNAscii(const unsigned char *buffer, int size)
{
int count1;
int count2;
const unsigned char *temp=buffer;
printf(" Address ");
for(count1=0; count1<16; count1++)
{// 메뉴 구분
printf("%02X ", count1);
}
for(count1=0; count1<16; count1++)
{
printf("%01X", count1);
}
printf("\n");
for(count1=0; count1<=size; count1+=16)
{// 메뉴 주소
printf("%#X ", buffer);
for(count2=0; count2<16; count2++)
{// 번지 주소
printf("%02X ", *buffer);
buffer++;
}
for(count2=0; count2<16; count2++)
{// 문자 판별65~90 97~122
printf("%c", ((*temp>=48)&&(*temp<=57)||
(*temp>=65)&&(*temp<=90)||
(*temp>=97)&&(*temp<=122)? *temp : '.'));
temp++;
}
printf("\n");
}
printf("\n");
return;
void PrintHexaNAscii(const unsigned char *buffer, int size);
int main()
{
int a = 0xffffffff;
PrintHexaNAscii((unsigned char *)&a, 100);
return 0;
}
void PrintHexaNAscii(const unsigned char *buffer, int size)
{
int count1;
int count2;
const unsigned char *temp=buffer;
printf(" Address ");
for(count1=0; count1<16; count1++)
{// 메뉴 구분
printf("%02X ", count1);
}
for(count1=0; count1<16; count1++)
{
printf("%01X", count1);
}
printf("\n");
for(count1=0; count1<=size; count1+=16)
{// 메뉴 주소
printf("%#X ", buffer);
for(count2=0; count2<16; count2++)
{// 번지 주소
printf("%02X ", *buffer);
buffer++;
}
for(count2=0; count2<16; count2++)
{// 문자 판별65~90 97~122
printf("%c", ((*temp>=48)&&(*temp<=57)||
(*temp>=65)&&(*temp<=90)||
(*temp>=97)&&(*temp<=122)? *temp : '.'));
temp++;
}
printf("\n");
}
printf("\n");
return;
}
'C언어 > 프로그래밍' 카테고리의 다른 글
달팽이배열 알고리즘 (0) | 2010.11.16 |
---|---|
로또 번호 생성 프로그램 (0) | 2010.11.11 |
원하는 수의 소수만 출력하는 프로그램 (0) | 2010.10.12 |
구구단 원하는 값 입력시 출력하는 프로그램 V.2 (for문 사용) (0) | 2010.10.11 |
구구단 원하는 값 입력시 출력하는 프로그램 (while문 사용) (0) | 2010.10.11 |