2011年3月17日 星期四

typedef 用法 (struct)


struct Student {
char name[32];
int number;
};

要使用時就必需宣告為


struct Student mystudent = {"John", 10};


我們可以為它加上別名


typedef struct {
char name[32];
int number;
} Student;


這樣就可以直接有一個Student型別可以使用


Student mystudent = {"John", 10};

2011年2月24日 星期四

記錄Windows XP 使用者每次登入的時間

從「開始」→「控制台」→「系統管理工具」,在「系統管理工具」的項目,接著點選「本機安全性原則」
在 「本機原則」→「稽核原則」,於右方 雙擊「稽核帳戶登入事件」,彈出「本機安全性設定」, 勾選 「成功」及「失敗」;同樣又雙擊「稽核登入事件」,勾選 「成功」及「失敗」,就能夠在「事件檢視器」中的「安全性記錄」看到登入的資料了

2011年2月12日 星期六

Drupal 7.0 日期變成 @datetime 的解決方法

會出這樣的問題是因為中文語系檔出狀況

把drupal-7.0.zh-hant.po這個檔案的

msgid "Submitted by !username on !datetime"
msgstr "由 !username 在 @datetime 發表"

改成

msgid "Submitted by !username on !datetime"
msgstr "由 !username 在 !datetime 發表"

然後去後臺把繁中刪除在新增就好了…

記得先取消預設才能刪除

2010年10月28日 星期四

WLNSC1000 改機資訊

改了以後可以跑自己的Apache server...也就是可以跑php囉..

See Log:
cat /var/log/messages


==========Setup Apache=========
in directory /mnt/C
tar zxvf apachexxxxx
vi /mnt/C/sys/etc/env-ng
RCNG=1

APACHE2=1 (if apache path is /mnt/C/sys/apache2)

APACHE22=1 (if apache path is /mnt/C/sys/apache22)


cp /mnt/C/sys/etc/php-ini-dist /mnt/C/sys/etc/php-ini
=========apache/conf/httpd.conf============
Modify

Listen your_ip:8080

ServerName your_ip
===========================================
Insert


AddType application/x-httpd-php .php


===========================================
reboot

Tips:
Manually start
/mnt/C/sys/apache2/bin/apachectl -f /mnt/C/sys/apache2/conf/httpd.conf &

2010年10月23日 星期六

Convert QString to Char*

If you went to convert prototype QString to char*,you can using this method:

int main(int argc, char **argv)
{
QApplication app(argc, argv);
QString str1 = "Test";

//method 1
strcpy(c_str2,str1.toUtf8());

//method 2
QByteArray ba = str1.toLatin1();
const char *c_str2 = ba.data();

printf("str2: %s", c_str2);
return app.exec();
}

2010年8月25日 星期三

Read and Write large file(over 2G) in C

If you want to open a large file in Linux


You can try it

Add those flag into your Makefile

-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

Modify you fseek and ftell to fseeko and ftello

Finish

2010年8月10日 星期二

IP的轉換

1、htonl ()和ntohl( )

u_long PASCAL FAR ntohl (u_long netlong);

u_short PASCAL FAR ntohs (u_short netshort);

ntohl( )-----網路順序轉換成主機順序

u_long PASCAL FAR htonl (u_long hostlong);

u_short PASCAL FAR htons (u_short hostshort);

htonl ()-----主機順序轉換成網路順序

2、inet_addr( )和inet_ntoa ( )

unsigned long PASCAL FAR inet_addr (const char FAR * cp);

char FAR * PASCAL FAR inet_ntoa (struct in_addr in);

inet_addr函數需要一個字串作為其參數,該字串指定了以點分十進位格式表示的IP位址(例如:192.168.0.16)。而且inet_addr函數會返回一個適合分配給S_addr的u_long類型的數值。

Inet_ntoa函數會完成相反的轉換,它接受一個in_addr結構體類型的參數並返回一個以點分十進位格式表示的IP位址字串。