测试代码

// C_test.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <string.h>


unsigned char change_endian(unsigned char c)
{
	unsigned char temp=0,i;
	for (i=0;i<8;i++)
	{
		if ( c & (1<<i) )
		{
			//置1
			temp |= 1<<(7-i);
		}
	}
	return temp;
}
void printf_test(char *fmt,...)
{
	printf(fmt);//__VA_ARGS__);
}

int _tmain(int argc, _TCHAR* argv[])
{
/*********************************************************************************************************************
*----------------------------------------------这种写法是对的
**********************************************************************************************************************/
#if 0
	typedef union
	{
		struct{
			int m1;
			int m2;
		};
		int a;
		int b;
		char c;
	}TestUnion
		;

	TestUnion uTmp;

	//uTmp.b=0x12345678;
	uTmp.m1=0x12345678;
	uTmp.m2=0x12345678;

	printf("TestUnion.c=0x%X\n",uTmp.c);
#endif
/*********************************************************************************************************************
*----------------------------------------------2013年7月2日16:41:32 这样写enum是错误的
**********************************************************************************************************************/
#if 0
	enum{
		ADB,
		DS,
	}TestList;

	TestList =1;
#endif

/*********************************************************************************************************************
*----------------------------------------------
**********************************************************************************************************************/
#if 0
	int a,b=1;
	a =b<<7;
	printf("%x",a);
#endif
/*********************************************************************************************************************
*----------------------------------------------研华
**********************************************************************************************************************/
#if 0
	int a ='\x022';
	int b ='\0123';
	printf("a=%d\n",a);
	printf("b=%d\n",b);

#endif
/*********************************************************************************************************************
*----------------------------------------------
**********************************************************************************************************************/
#if 0
	static unsigned char g_osd_buffer[10][10];
	char *osd_buffer =(char *)( g_osd_buffer[2] );
	
	printf("%d\n",*osd_buffer);
#endif
/*********************************************************************************************************************
*----------------------------------------------注意这个实际上不是大小端调整
**********************************************************************************************************************/
#if 0
	unsigned char a =0x24,b;
	
	b =change_endian(a);
	printf("b =%x\n",b);

	printf("hello world!");
#endif
/*********************************************************************************************************************
*----------------------------------------------HuaWei Error
**********************************************************************************************************************/
#if 0
	char *pStr ="Hello";
	char pBuf[]="Hello";

	int a,b,c,d,e;
	a =sizeof(pStr);//4
	b =sizeof(pBuf);//5....应该是6

	c =strlen(pStr);//5
	d =strlen(pBuf);//未知.....应该是5

	printf("a=%d,b=%d,c=%d,d=%d\n",a,b,c,d);
#endif
	/*********************************************************************************************************************
	*----------------------------------------------HuaWei Test2
	**********************************************************************************************************************/
#if 0
	typedef union
	{
		int		a;
		short	b[6];
		char	c;
	}TestUnion;//ARM系统,4字节对齐

	int a,b,c,d,e;

	TestUnion Test,*pTest;

	a =sizeof(TestUnion);//12
	b =sizeof(pTest);//4
	c =sizeof(*pTest);//12
	d =sizeof(Test);//12

	printf("a=%d,b=%d,c=%d,d=%d\n",a,b,c,d);//做的正确
#endif
/*********************************************************************************************************************
*----------------------------------------------
**********************************************************************************************************************/
#if 0
	#define Q(n)  #n
	printf("%s\n",Q(2));
#endif

/*********************************************************************************************************************
*----------------------------------------------
**********************************************************************************************************************/
	int a =10;
	printf_test("Helllll:%d\n",a);
	printf("Hello World   Q(4) \n");

	return 0;
}

2014.4.16

2014.4.17

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值