C: Error in srand (time (NULL));

2

I'm doing a little game in C (college project) and am encountering an error in main, it follows:

int main () {
    int x, y, i, j, linha, cnt=1, jl=0, jc=0, jogada_a=0, jogada_b=0;
    char coluna, jogador;
    srand(time(NULL));
    x = (rand() % 5) +2;
    y = (rand() % 5) +2;
    gerar();
    matriz[x][y] = '0';
}

The error requests time declaration:

  

error: 'time' was not declared in this scope

    
asked by anonymous 11.10.2017 / 18:47

2 answers

7

Failed to include headers :

#include <stdlib.h>  /* rand(), srand() */
#include <time.h>    /* time() */
    
11.10.2017 / 18:52
-1

After the function srand(time(NULL)) it is necessary to use FOR.

    
08.08.2018 / 03:07