random number gen/ SLD

im making a SDL game and i am having trouble with my random number generator?
when i run it said that time was not declared? on line 15

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <cstdlib>
#include<iostream>
#include "SDL/SDL.h"
#include <string>

SDL_Surface *screen;

void borders(int x, int y, Uint32 color,int w,int h){
    SDL_Rect Tmp = {x,y,w,h};
    SDL_FillRect(screen,&Tmp,color);
}

int main(int argc, char** argv)
{
        srand(time(0));// here is the problem 
        int width=640;
        int height=480;
        SDL_Init(SDL_INIT_EVERYTHING);



        screen = SDL_SetVideoMode(width, height, 32, SDL_SWSURFACE);
        bool running = true;
        const int FPS = 30;
        Uint32 start;
        int foodX = rand()%620+10;
        int foodY = rand()%460+10;
Last edited on
time was not declared?


Don't forget to #include <ctime>
oh ok thanks @wildblue yeah on netbeans you dont haft to add that
thank you for the help
Topic archived. No new replies allowed.