Wierd error HELP

I'm writing this very simple code here and it should work just fine.. But i get like 50 errors in stat.h?
such as:

d:\mingw\include\sys\stat.h|180|error: '_off_t' does not name a type|
d:\mingw\include\sys\stat.h|180|error: 'time_t' does not name a type|
d:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar|146|error: '::fwide' has not been declared|

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
29
30
#include <iostream>
#include <ctime>
#include <random>

using namespace std;

int main()
{

mt19937 randomGenerator(time);
uniform_real_distribution<float> attackRoll(0.0f, 1.0f);

cout << "I am attacking snake! ";

float attack = attackRoll(randomGenerator) ;

if (attack <= 0.3f)
{
    cout << "I hit the snake! Yaaaas!"

    else
    {
    cout << "I missed"
    }
}

cout << "Attack was: " << attack;
    return 0;
}
closed account (LUf3AqkS)
I made a few corrections for you. time needed a parameter, there were some semicolons missing and the else statement was inside the if statement instead of after it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <ctime>
#include <random>

using namespace std;

int main()
{
    mt19937 randomGenerator(time(nullptr));
    uniform_real_distribution<float> attackRoll(0.0f, 1.0f);

    cout << "I am attacking snake! ";

    float attack = attackRoll(randomGenerator);

    if(attack <= 0.3f)
        cout << "I hit the snake! Yaaaas!";
    else
        cout << "I missed";

    cout << "\nAttack was: " << attack;
}

Last edited on
For starters you seem to be missing several semicolons, and you also have misplaced braces.

You may also want to review your documentation for using creating and using the random generator.



Topic archived. No new replies allowed.