Add tags

Add tags to the following comment
とりあえず、縮めてないです。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>

#define QWORD unsigned long long
#define DWORD unsigned long
#define WORD  unsigned short
#define BYTE  char

int put_unit(char * p,int n,char u){
    if(n) return sprintf(p,"%d%c",n,u);
    if(u=='B') return sprintf(p,"B");
    return 0;
}

void conv_byte(char *p,QWORD num){
    int i;
    if(num==0) sprintf(p++,"0");
    for(i=6;i>=0;i--)
        p+=put_unit(p,(num>>(10*i))&0x3ff,"BKMGTPE"[i]);
}

void conv_put(char *buf,QWORD n){
    conv_byte(buf,n);
    printf("%Ld=%s\n",n,buf);    
}
int main(){
    char buf[64];
    
    conv_put(buf,0);
    conv_put(buf,(BYTE)-1);
    conv_put(buf,(WORD)-1);
    conv_put(buf,(DWORD)-1);
    conv_put(buf,(QWORD)-1);
    
    return 0;
}

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...