1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ある長さの16進ダンプを表示する。

Last updated at Posted at 2024-11-15

x 過去ログを見よ!!
x M5NanoC6では、予定は、未定

オンラインコンパイラ



#include <iostream>
using namespace std;


//ある長さを16進に変換 256ぐらい
char *hex_conv(const unsigned char *a,int n) {

  static char b[(256*3) + 1];
  char h[16] = {'0', '1', '2', '3', '4', '5', 
    '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
  
  b[0] = 0;
  if(n>256){n=256;}
  for(int i=0;i<n;i++){
    b[i*3+0] = h[a[i] >> 4];
    b[i*3+1] = h[a[i] & 0x0f];
    b[i*3+2] = ':';
    //printf(".");
  }
  if(n != 0) {b[n*3-1] = 0;}
  //printf("\n");
  //printf("[%s]\n",b);
  
  return ( b ); //戻り値
  
}//mac_add_conv


int main(void){
    // Your code here!
    
    char kk[] = {
      "1234567890123456"
      "1234567890123456"
      "1234567890123456"
      "1234567890123456"

      "1234567890123456"
      "1234567890123456"
      "1234567890123456"
      "1234567890123456"

      "1234567890123456"
      "1234567890123456"
      "1234567890123456"
      "1234567890123456"

      "1234567890123456"
      "1234567890123456"
      "1234567890123456"
      "1234567890123450"
    };
    
    char *dd = hex_conv((unsigned char *)kk,3);
    printf("%s\n",dd);
    
}



31:32:33

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?