如何在linux上寫執行時間的程式? - Linux

Jake avatar
By Jake
at 2011-09-09T03:01

Table of Contents

※ 引述《spiderman007 (千里之外)》之銘言:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#ifdef _WIN32_
#include <windows.h>
#else
#include <unistd.h>
#define Sleep(a) usleep(a*1000)
#endif

int main(void){
time_t t1,t2; // typedef time_t long;
t1 = time(0);
Sleep(1234);
t2 = time(0);
printf("%ld secs\n",t2-t1);
gtc(stdin);
return 0;
}

--
~~於是,銀河的歷史又被海賊抹黑了好幾百頁。
咦?的歷史又被抹黑了好幾百頁!?
- A23203 -
BM4GRM Harlock WolfLord
<<上站通知>> -- 我來啦!

--
Tags: Linux

All Comments

Bethany avatar
By Bethany
at 2011-09-10T11:32
那個 gtc 是不是應該是 getc 才對...
Genevieve avatar
By Genevieve
at 2011-09-12T11:02
嘿啊~~ 打錯了

9/15、9/17 Linux 核心軟中斷實作-對照BSD之設計技術研討會

Heather avatar
By Heather
at 2011-09-08T18:56
Embedded Linux System 系列研討會 - 二十二 台北兩場次 2011/9/15(四) ...

找不到網路介面

Andrew avatar
By Andrew
at 2011-09-08T17:41
我主機上有兩張網卡,平常沒什麼問題 可是有時開機後會只找到MB內建的 重開幾次後PCI上的就又可用了 以下是無論有沒有抓到第二張網卡 $ lspci: 02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8 ...

Ubuntu寫C

Oscar avatar
By Oscar
at 2011-09-08T17:18
※ 引述《aurora9624 (我還太淺)》之銘言: : 請問一下板上各位高手 : 小弟我現在用 Ubuntu 11.04的版本 : 最近要寫程式 看了一些文章到現在還是不太會.... : 我已安裝許多開發工具了 : and#34;blocks IDEand#34; and#34;Geanyand#34 ...

RE:SSD磁柱分配方式

Isabella avatar
By Isabella
at 2011-09-08T16:02
Device Boot Start End Blocks Id System /dev/sda1 * 2048 257039 127496 83 Linux /dev/sda2 ...

mount iso scripts 抓錯

Joe avatar
By Joe
at 2011-09-08T10:23
請前輩幫忙抓錯,有一個 bash mount iso script, 用 Run in Terminal 跑是正常的,可以創建目錄,也可以 mount。 但是用 Scripts -andgt; mount.sh 跑卻是不能創建目錄,也不會 mount。 系統是 debian 6, Gnome, 安裝了 ...