// 位段赋值的例子
#include
int main()
{
unsigned char puc[4];
struct tagPIM
{
unsigned char ucPiml;
unsigned char ucData0 : 1;
unsigned char ucData1 : 2;
unsigned char ucData2 : 3;
}*pstPimDat...
分类:
编程语言 时间:
2015-05-11 16:11:06
阅读次数:
185
1. YUV420 -> Mat 可用于转换接受到的YUV视频源到OpenCV可以识别的数据Mat myuv( Frame_Height + Frame_Height / 2, Frame_Width, CV_8UC1, (unsigned char *) YUV420_Image_Buffer);...
分类:
其他好文 时间:
2015-05-11 16:05:42
阅读次数:
1033
// 自己的strncpy与库里的strncpy区别
#include
#define CHAR char
#define ULONG unsigned long
CHAR *VOS_strncpy(CHAR *pcDest, const CHAR *szSrc, ULONG ulLength)
{
CHAR *pcPoint = pcDest;
// 对指针进行判空
if ((NU...
分类:
编程语言 时间:
2015-05-11 14:48:35
阅读次数:
163
Sizeof与Strlen的区别与联系一、sizeof sizeof(...)是运算符,在头文件中typedef为unsigned int,其值在编译时即计算好了,参数可以是数组、指针、类型、对象、函数等。它的功能是:获得保证能容纳实现所建立的最大对象的字节大小。由于在编译时计算,因此sizeof不...
分类:
其他好文 时间:
2015-05-11 14:42:01
阅读次数:
159
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
For example, the 32-bit integer ’11' has binary representation 00000000000000000000000000001011, so the function should return 3....
分类:
其他好文 时间:
2015-05-11 10:53:29
阅读次数:
135
unsigned int BKDRHash(char*str){ unsigned int seed=131 ;// 31 131 1313 13131 131313 etc.. unsigned int hash=0 ; while(*str) { hash=hash*seed...
分类:
其他好文 时间:
2015-05-11 00:03:25
阅读次数:
173
一个字节中二进位1的个数
两个相似的方法,一个右移所查看的字节;一个查看左移1.
#include
int getOneBits(unsigned char num)
{
int count = 0;
for(int i = 0; i < 8; i++)
{
if((num & (1 << i)) != 0)
coun...
分类:
其他好文 时间:
2015-05-10 22:26:27
阅读次数:
140
本文介绍了cin重载的operator>>()函数、get()函数、getline()函数以及相应的eofbit和failbit问题。 cin重载了operator>>()函数来实现对任何类型数据的输入操作,重载的类型如下: int& short& long& unsigned int& unsig...
分类:
其他好文 时间:
2015-05-10 15:31:22
阅读次数:
178
递归实现是最常想到的方法,代码如下:
//递归方式
long Fibonacci(unsigned n)
{
if (n==0)
{
return 0;
}
else if (n==1)
{
return 1;
}
else
{
return Fibonacci(n-1)+Fibonacci(n-2);
}
}
显然递归并不是最好的方法,当n较大时效率将非常低下。
...
分类:
其他好文 时间:
2015-05-10 12:59:56
阅读次数:
159
抛出问题
今天在写程序的时候遇到了一个以前没有暴露出来的问题,问题如题目所示。下面写了一个小的测试程序,如下:
#include
#include
int main(){
unsigned char *ua = (unsigned char*)malloc(sizeof(unsigned char) * 3);
char line[40] = "177 100 88";
ssc...
分类:
其他好文 时间:
2015-05-09 22:11:11
阅读次数:
184