2008年6月25日 星期三

Dev-C++ - wanna make with '-D'

    在工作站編譯時可以用 make -D define_variable 以此決定要用哪種 code

    最近使用 Dev-C++ 並且將自己寫的 code 從 FreeBSD 移值至 Windows
    常常使用一些系統相依性的函數 偶時需要 windows.h 或什麼的

    這時常用

    #ifdef _WORK_FOR_WIN32_

    #include <windows.h>
    #include <io.h>

    #endif

    現在 不必自行改 header file 去定義 _WORK_FOR_WIN32_
    可以透過 Dev-C++ :

        [專案]->[參數]->[編譯器]

        增加 -D _WORK_FOR_WIN32_

    原先摸很久找不太到 原來 -D 這個參數可以直接加到 gcc or g++ 啊
    現在編譯的方式又乾淨許多了  :D

暑假尚未開始

碩班的生活,沒想到期末考都很早地考完,唯一的缺點是我修了一門期末要上台報告的課,必需搞到七月初才能正式結束這學期的課程。

一不留意,已經在中正待了接近一年,去年我是在七月底進宿舍的。仔細回想,這一年嘛,說沒學到東西也不是,但總覺得心中有點空虛的感覺,大概是學了不少我認為出去工作再學就好的東西吧?說真的,我有種很想趕快畢業的念頭,同時也思考自己是不是適合往博班發展?總覺得博班才是做研究的開始,碩班像極打雜的掃地僧,各憑本事混吃混喝。前陣子猶疑,最近比較定下心了,我想,出去工作才是我想要的生活,未來若沒經濟壓力,加上能申請上的話,再回學校吧?

說得好像已經畢業似的。

下學期我還是想把行銷管理的課程好好地上過一遍,碩一上期中後因為常常膩於程式中,不久也作罷了。除此之外,還有不少課想去聽聽,不曉得未來的生活是否還能抓的穩步調呢?

2008年6月24日 星期二

[C] long long & printf

    long long x;

    Windows:
                printf( "%I64d\n" , x );
    Unix:
                printf( "%lld\n" , x );

--
    "%qd" ?

2008年6月22日 星期日

[C] fopen with 'a' & fseek

            fopen with 'a' 無法使用 fseek 對檔案指標進行倒退嚕
            這兩天運氣不怎好  總是卡在奇怪的 bug 中
            真的是太嫩了  還差得遠

                =========================================================
                = By finwater (cheer up) @ Mon Jun 23 20:15:07 2008
                =
                fopen with flag 'a' 的 'a' 是 append 的意思
                所以 write 的 data 會被自動 append 到檔案的最後
                無論此時 offset 在哪
                但還是可以使用 fseek 對 file pointer 的 offset 進行操作
                =========================================================

    @ code 1 : fopen with 'ab+'

        #include <stdio.h>
        #include <stdlib.h>

        int main(int argc, char *argv[])
        {
                FILE * fd = fopen ("dd" , "ab+");
                fd = fopen ("dd" , "w+");
                fclose ( fd );

                fd = fopen ("dd" , "ab+");
                fprintf( fd , "0123456789" );

                fseek( fd , -5 , SEEK_CUR );

                fprintf( fd , "0123456789" );

                fclose ( fd );
                return 0;
        }

        結果: 01234567890123456789

    @ code 2 : fopen wtih 'rb+'
        #include <stdio.h>
        #include <stdlib.h>

        int main(int argc, char *argv[])
        {
                FILE * fd = fopen ("dd" , "ab+");
                fd = fopen ("dd" , "w+");
                fclose ( fd );

                fd = fopen ("dd" , "rb+");
                fprintf( fd , "0123456789" );

                fseek( fd , -5 , SEEK_CUR );

                fprintf( fd , "0123456789" );

                fclose ( fd );
                return 0;
        }

        結果: 012340123456789

2008年6月21日 星期六

大量縮圖 By Irfan View

    http://www.irfanview.com/
    http://www.irfanview.com/main_download_engl.htm

    Step 1 :
        [File] -> Batch Coversion/Rename

    Step 2 :
        透過右上角視窗,可以挑選待處理的照片
        記得請將[檔案類型]改成 All files (*.*)
        選好照片後,請點選 [Add] 或是對指定目錄點選 [Add all]
        接著就會在右下角視窗記錄著

    Step 3 :
        目前打算將原始檔 jpg 檔轉成較小的圖檔
        [Batch conversion settings] -> Output format: JPG - JPG/JPEG Format
        勾選 [Use advanced options] -> Advanced

    Step 4 :

        設定 Advanced 參數,我常用的是將照片的寬設成 1024
        [RESIZE] -> Set long side to: 1024
        勾選常用選項
        [Preserve aspect radio(proportional)]
        [Use Resample function(better quality)]
        [Don't enlarge smaller images]

    Step 5 :
        選擇輸出的位置
        [Output directory for result files]

    Step 6 :
        [Start Batch]