2009年8月28日 星期五

strstr

strstr(const char *s1, const char *s2);
find s2 from s1, search until 0
ex:
char a[100] = "bbbbaaaa";
a[2]= 0;
printf("%d\n", strstr(a, "a"));
---> can not find


2009年2月25日 星期三

friend class

ex:
if A class wants B class can access A's protected method,
A must define B as its friend class

2009年2月1日 星期日

void parameter

in c,
int a()  &  int a(void) are different

a() can accept an infinite number of parameters,
a(void) can accept zero parameter

2009年1月19日 星期一

function pointer in c++

testFunPtr is not a static function 
testFunPtr2 is a static function

correct:
int (com_scsi_command_driver::*pt2Function)()=       &com_scsi_command_driver::testFunPtr;
int (*pt2Function)()= 
&com_scsi_command_driver::testFunPtr2;

wrong:
int (*pt2Function)()= &com_scsi_command_driver::testFunPtr;




2009年1月14日 星期三

file IO

in fcntl.h
O_RDONLY

2008年12月28日 星期日

typeof

get type:

ex:
typeof(int) intVar1=1;
typeof(intVar1) intVar2=intVar1;
typeof(int*) intPtrVar1=&intVar1;
typeof(intPtrVar1) intPtrVar2=intPtrVar1;
printf("%d %d %d %d\n", intVar1, intVar2, *intPtrVar1, *intPtrVar2);


result: 1 1 1 1