C language character to decimal

C language character to decimal

char chr_to_dec(char chr)
{
	char value = 0;

	if ((chr >= 'a') && (chr <= 'z')) {
		chr = chr - 32;
	}

	if ((chr >= '0') && (chr <= '9')) {
		value = chr - 48;
	} else if ((chr >= 'A') && (chr <= 'Z')) {
		value = chr - 65 + 10;
	}

	return value;
}

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example