05AB1E icon indicating copy to clipboard operation
05AB1E copied to clipboard

Program to demonstrate name

Open JL2210 opened this issue 4 years ago • 1 comments

I have a program here that demonstrates how the name works.

Run this as program-name | base64:

#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int le_hex = 0x1EAB05;
int be_hex = 0x05AB1E;

static inline int is_le(void)
{
    unsigned a;
    srand(time(NULL));
    a = rand()%0x100;
    if(*(unsigned char *)&a == a)
        return 1;
    else
        return 0;
}

int main(void)
{
    void *hex = is_le() ? &le_hex : &be_hex;
    ((char *)hex)[4] = 0;
    fputs(hex, stdout);
    return 0;
}

I had to reverse the name in hex for my little-endian machine, though.

JL2210 avatar Sep 17 '19 20:09 JL2210

Pure bash: echo "05ab1e" | xxd -ps -r | base64 -

sportshead avatar Mar 26 '20 09:03 sportshead