[問題] wxwidgets寫亂數

看板C_and_CPP (C/C++)作者 (左)時間13年前 (2012/10/14 04:05), 編輯推噓0(005)
留言5則, 5人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) wxDevc++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 想寫亂數 但用C++的寫法似乎行不通 compiler一直不認得srand 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): expected constructor, destructor, or type conversion before '(' token (在srand(time(NULL));這行 程式碼(Code):(請善用置底文網頁, 記得排版) 亂數部分 #include <stdio.h> #include <stdlib.h> #include <time.h> srand(time(NULL)); int randomnumber = rand()%n+1; 補充說明(Supplement): 老師只在講義上寫了randomize()就和rand()就沒了 如果要使用randomize應該include什麼才對?? 或是 wxwidgets的亂數該怎麼寫@@? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.178.18

10/14 04:26, , 1F
srand ( (unsigned)time(NULL) ); 強制轉型試試
10/14 04:26, 1F
有試過 但一樣無法 一樣會顯示expected constructor, destructor, or type conversion before '(' token

10/14 04:47, , 2F
這樣看不出來, 請給多一點上下文
10/14 04:47, 2F
呃...因為扣掉srand(time(NULL))compile會過程式執行也沒問題

10/14 04:56, , 3F
line, column 都有給吧?
10/14 04:56, 3F
line和column是..? ※ 編輯: Ladieux 來自: 140.113.178.18 (10/14 08:06)

10/14 08:07, , 4F
去google rand() 第三個就有範例了...
10/14 08:07, 4F

10/15 08:56, , 5F
看起來像放錯位置
10/15 08:56, 5F
文章代碼(AID): #1GUScB2z (C_and_CPP)
文章代碼(AID): #1GUScB2z (C_and_CPP)