c# 字节十六进制转十进制_用C中的十进制,八进制和十六进制数字初始化字节数组...

c# 字节十六进制转十进制

C中的字节数组 (byte array in C)

In C programming language, an unsigned char type can be used to declare byte array in C programming language. An unsigned char can contain a value from 0 to 255, which is the value of a byte.

在C编程语言中, 无符号char类型可用于声明C编程语言中的字节数组 。 无符号字符可以包含0到255之间的值,该值是一个字节的值。

In this example, we are declaring 3 arrays – arr1, arr2, and arr3, arr1 is initialising with decimal elements, arr2 is initialising with octal numbers and arr3 is initialising with hexadecimal numbers.

在此示例中,我们声明了3个数组-arr1 , arr2和arr3 , arr1用十进制元素初始化, arr2用八进制数初始化, arr3用十六进制数初始化。

Example:

例:

#include <stdio.h>

int main()
{
	//declaring array, initialising with decimal values	
	unsigned char arr1[]={10, 20, 30, 40, 50};
	//declaring array, initialising with octal values	
	unsigned char arr2[]={010, 077, 023, 045, 057};		
	//declaring array, initialising with hexadecimal values	
	unsigned char arr3[]={0x10, 0xAA, 0x67, 0xA1, 0xFF};	
	int i;
	
	//printing the numbers
	printf("arr1...\n");
	for(i=0; i<5; i++)
		printf("%d ",arr1[i]);
	printf("\n");

	//printing the numbers
	printf("arr2...\n");
	for(i=0; i<5; i++)
		printf("%o ",arr2[i]);
	printf("\n");
	
	//printing the numbers
	printf("arr3...\n");
	for(i=0; i<5; i++)
		printf("%X ",arr3[i]);	
	printf("\n");
	
	return 0;	
}

Output

输出量

arr1...
10 20 30 40 50 
arr2...
10 77 23 45 57 
arr3...
10 AA 67 A1 FF 


翻译自: https://www.includehelp.com/c-programs/initialising-byte-array-with-decimal-octal-and-hexadecimal-numbers-in-c.aspx

c# 字节十六进制转十进制

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值