将数组转换为无符号整数

时间:2013-09-06 07:06:03

标签: c arrays int unsigned

您好我有一个二维array[8][8],这些元素都填充了10。所以我的问题是:如何将一整行转换为8位长的无符号整数?

我在C编码。

1 个答案:

答案 0 :(得分:0)

像这样:

int array[8][8]; /* this is what you have */

unsigned row0 = 0;
int i;
for( i = 0; i < 8; i++ ) row0 |= (unsigned)array[0][i] << i;

/* row0 now contains the converted number */

这假设您的数据首先是最不重要的。