-3
我需要生成一個隨機數,而不使用「隨機」功能,所以我發現這個代碼,給我mlliseconds系統:產生一個隨機數沒有隨機函數
#include <stdio.h>
#include <sys/timeb.h>
int main()
{
struct timeb tmb;
ftime(&tmb);
printf("tmb.time = %ld (seconds)\n", tmb.time);
printf("tmb.millitm = %d (mlliseconds)\n", tmb.millitm);
return 0;
}
這是工作好,直到我試圖以這種方式在struct結構中使用它:
#include <sys/timeb.h>
#include "stdlib.h"
struct Num{
struct timeb tmb;
ftime(&tmp);
};
int main()
{
return 0;
}
它在{ftime}處給出一個錯誤。 有幫助嗎?
「出錯」?而實際的錯誤是? – dhke
[錯誤]預期在'ftime'之前的限定符列表 –
啊,剛剛看到它:你爲什麼試圖從結構的聲明(即函數外部)調用函數?因爲......那麼......爲什麼會這樣呢? – dhke