引用 | 編輯
cmovies
2006-04-20 17:30 |
1樓
▲ ▼ |
請問你要 DOS/Windows/Windows Console 哪一種環境下執行?
用的是哪種編譯器 Visual Studio ?? 還是 DJGPP?? x0 |
引用 | 編輯
leacks
2006-04-20 19:33 |
2樓
▲ ▼ |
我是用這個Microsoft Visual Studio 2005
windows下執行! 主要是因為我寫了一個計算pi的程式,但為了更詳細,時間就越久. 雖然我可以預估自己電腦的時間,但一但拿去別台用那預估的時間就破功了! 所以我想做一個活動式的預估時間! x0 |
引用 | 編輯
cmovies
2006-04-20 22:26 |
3樓
▲ ▼ |
如果時間不會超過 49.7 天, 可以用 DWORD GetTickCount(). 這個單位為 ms
不然就用 C runtime libary 中的 double difftime( time_t timer1, time_t timer0 ); 這個算出來的整數部分就是以秒為單位 x0 |
引用 | 編輯
cmovies
2006-04-21 12:26 |
5樓
▲ ▼ |
GetTickCount 有錯誤還是 difftime 有錯誤?
編譯錯誤還是執行時出現錯誤訊息? 錯誤訊息是什麼? 這應該只要 include 相對應的 header file 就可以了 你可以查詢 MSDN x0 |
引用 | 編輯
leacks
2006-04-25 18:56 |
6樓
▲ ▼ |
兩個都有錯誤.
可以的話麻煩寫詳細一點說要怎樣用吧! 因為我也不知道要使用這個語法時要宣告什麼. 你就舉例DWORD GetTickCount()或double difftime( time_t timer1, time_t timer0 ); 麻煩你了,謝謝! 宣告include"??" <----??麻煩一下 int??; or double??; <----??這個也是 =====取得第一次秒數令他為x====== <----這只要寫一個就好了 程式(原本的) =====取得第二次秒數令他為y====== sorry我是新手! x0 |
引用 | 編輯
cmovies
2006-04-25 21:16 |
7樓
▲ |
#include <stdio.h>
#include <windows.h> // Windows function (GetTickCount, ....) #include <time.h> // time, difftime, ... int main(int argc, char* argv[]) { DWORD stick, etick; time_t start, finish; time(&start); stick = GetTickCount(); printf("Test beging...\n"); // test function time(&finish); etick = GetTickCount(); printf("Elapsed second(s)=%lf, Elapsed tick(s)=%u\n", difftime(finish, start), etick-stick); return 0; } x1 |