i watched this tutorial video http://thenewboston.org/watch.php?cat=14&number=13
and for some reason it doesn't work..
it says time is undeclared for some reason

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>


int main(void)
{
    int i=0;
    srand(time(NULL));
    while (i<200)
    {
    printf("%d\n", 1+rand()%6);
    i++;
    system("cls");
    }
    
    system("PAUSE");
    return 0;
    }

Recommended Answers

All 2 Replies

include the header

#include <ctime>

Edit: I change my mind,you should have posted this in the C forum
i think its

#include <time.h>

It's also probably not a good idea to clear the screen after every iteration of the loop without some kind of pause involved. The program will run too quickly to see the changes and will look like it's just printing a single random number.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.