// 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