2012-07-19 62 views
-1

這是我第一次使用Eclipse進行C++編程,而且我遇到了問題。我已經包含「time.h」,但錯誤(函數'srand'無法解決)仍然出現。請幫幫我!非常感謝函數'srand'無法解決? (我使用Ubuntu操作系統和Eclipse)

#include "iostream" 
#include "time.h" 
using namespace std; 
#define MAX 100 
void InputArray(int a[],int n) 
{ 

    srand((unsigned)time(NULL)); //error here Function 'srand' could not be solved 
     a[0]=rand()%10; //and here 
     for(int i=1; i<n; i++) 
      a[i]=a[i-1] + rand()%10 + 1; 
} 
int main() { 
    int a[MAX], n; 
    InputArray(a,n); 
    return 0; 
} 
+0

另外,請不要只是一味地添加代碼完全改變它的問題... – 2012-07-19 08:02:20

+2

是否真的說「無法得到解決」 ? – 2012-07-19 08:02:43

回答

4

你忘了

#include <stdlib.h> 
+0

我只是#include 但仍然錯誤:( – LucidLynx 2012-07-19 07:59:06

+1

@ArchDevil同樣的錯誤嗎?你是'inlucde'還是'include'? – 2012-07-19 08:00:35

+1

@ArchDevil你用引號'「」'而不是'<>'。 – Mysticial 2012-07-19 08:01:04