Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: fs444 on June 04, 2017, 12:54:48 am

Title: Downloading time.h
Post by: fs444 on June 04, 2017, 12:54:48 am
When I write
Code
#include <time>
and compile code, I got error
Quote
fatal error: time: No such file or directory
Where I can download time.h ?
I use CodeBlocks 16.01 and MinGW.
Title: Re: Downloading time.h
Post by: oBFusCATed on June 04, 2017, 01:30:43 am
If you want time.h then tell the compiler to include it using #include <time.h>!
Title: Re: Downloading time.h
Post by: fs444 on June 04, 2017, 03:24:02 pm
I have done it already. This is full program code
Code
//casting of a hexahedral bone 6000 times
#include <iostream>
#include <iomanip>
#include <stdlib>
#include <time>

using namespace std;

int main()
{
    const int arraySize = 7;
    int face, frequency[arraySize] = {0};

    srand(time(NULL));

    for (int roll = 1; roll <= 6000; roll++) {
        face = rand() % 6 + 1;
        ++frequency[face];
    }

    cout << "Gran" << setw(17) << "Chastota" << endl;

    for (face = 1; face <= arraySize; face++)
        cout << setw(4) << face
            << setw(17) << frequency[face] << endl;

    return 0;
}
Title: Re: Downloading time.h
Post by: stahta01 on June 04, 2017, 03:27:10 pm
If you want time.h then tell the compiler to include it using #include <time.h>!

"time" is NOT the same as "time.h" that is what oBFusCATed posted.
Please read and fix your code or go to a site the supports programming!

Edit: "time" is also not the same as "ctime".

Read the rules: http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)

Tim S.
Title: Re: Downloading time.h
Post by: fs444 on June 05, 2017, 09:27:59 pm
Yes, you right, time.h resolved this problem. Thank you.