Author Topic: Downloading time.h  (Read 382 times)

Offline fs444

  • Single posting newcomer
  • *
  • Posts: 3
Downloading time.h
« on: June 04, 2017, 12:54:48 am »
When I write
Code: [Select]
#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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10277
Re: Downloading time.h
« Reply #1 on: June 04, 2017, 01:30:43 am »
If you want time.h then tell the compiler to include it using #include <time.h>!
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline fs444

  • Single posting newcomer
  • *
  • Posts: 3
Re: Downloading time.h
« Reply #2 on: June 04, 2017, 03:24:02 pm »
I have done it already. This is full program code
Code: [Select]
//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;
}

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5943
    • My Best Post
Re: Downloading time.h
« Reply #3 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

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline fs444

  • Single posting newcomer
  • *
  • Posts: 3
Re: Downloading time.h
« Reply #4 on: June 05, 2017, 09:27:59 pm »
Yes, you right, time.h resolved this problem. Thank you.