2012年4月7日星期六

simple example about write() and read()

unsigned char str1[]="I Love You";
    int n[5];
    ifstream in("xxx.xxx");
    ofstream out("yyy.yyy");
    out.write(str1,strlen(str1));//put the string str1 write in yyy. yyy file
       in.read((unsigned char*)n,sizeof(n));//from xxx.xxx  read designated integer, Note: type conversion
    in.close();out.close();

2012年3月12日星期一

setOn &setOff

void setOn(unsugned int&val, int bitNo){
val = val | (1<<bitNo);
}

bol setOff(unsigned int&val, int bitNo){
val = val & ~(1<<bitNo);
}