*mmap [#rd2dff65] -[[参考>http://www.atmarkit.co.jp/ait/articles/1201/18/news133.html]] -機能:ファイルとメモリの同一視(仮想メモリ技術) --読み込み専用なら,メモリから読み出しがそのままファイル読み出しに相当. --書き込み専用なら,メモリへの書き込みがそのままファイル書き込みに相当. -メリット --カーネルとコピープログラムの間でデータのコピーが発生しないので,高速. --iostreamなんて使うよりはよほど早い. *printfのバッファクリア [#k14c74e4] -printfが表示されないときに #include <stdio.h> #include <stdlib.h> int main(void) for (i = 0 ; i < 3; i++) { printf("*"); fflush(stdout); sleep(1); } } *void*のoffset [#k44c5f76] #include <stdio.h> int main(void) { void* a = (char*)0x01; a = (void*)((char*)a + 0x0F); printf("%p\n", a); } *inputデバイスに入出力 [#g4c1f436] -input subsystemを使うとできる -[[sample>https://github.com/hamko/sample/tree/master/inputsubsystem]] *日付からUNIX TIMEを得る [#a2e06324] #include <ctime> #include <cstdio> #include <cmath> int main(void) { int y = 2015; int m = 5; struct tm t; time_t timer; timer = mktime(&t); for (int d = 3; d < 30; d++) { t.tm_year = y - 1900; t.tm_mon = m - 1; t.tm_mday = d; t.tm_hour = t.tm_min = t.tm_sec = 0; timer = mktime(&t); printf("%d %d (%ld)\n", d, (int)round((double)timer/60/60/24), timer); } } *ブラウジング [#o1887f44] -curlとlibxmlを使う. -ログイン情報は,httpクッキー情報を付記する必要がある(超面倒) |