#include <stdio.h>
#include <stdbool.h>

bool toHex1(int val, char *dstPtr){
	if (dstPtr == NULL) {
		return false;
	}
	sprintf(dstPtr, "%X", val);
	return true;
}
bool toHex2(int val, char *dstPtr) {
	if (dstPtr == NULL) {
		return false;
	}
	
	char wrkstr[5] = {0};
	static const int maxbit = 16;
	int wrkval = val;
	int bit = 0;
	while(bit <= maxbit) {
		wrkval = (val >> bit & 0xF);
		if (wrkval == 0) {
			break;
		}
		if (wrkval < 10) {
			wrkstr[bit/4] = '0' + wrkval;
		} else {
			wrkstr[bit/4] = 'A' + (wrkval - 10);
		}
//		printf("%d", wrkval);
		bit += 4;
	}
	
	int idx = bit / 4 - 1;
	while(idx >= 0) {
		dstPtr[idx] = wrkstr[bit / 4 - idx - 1];
		idx--;	
	}

	return true;		
}

int main(void) {
	int val=0;
	char res[20];
	
	if(toHex1(val, res)) {
		printf("%d %s\n", val, res);
	}
	res[0] = 0x0;
	if(toHex2(val, res)) {
		printf("%d %s\n", val, res);
	}
	
	return 0;
}
