Cant use if with rand()

I am trying to make a program where you are given random numbers and you need to type in those random numbers and then it will output you a message but it wond do it.

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

using namespace std;

int main()
{
    int X;
    string type;

    for(int R = 0; R < 1; ++R)
    {
        X = rand() % 15;
    }

    cout << X << endl;
    cin >> type;

    if(type == X)
    {
        cout << "Test" << endl;
    }
}


errors:

C:\Users\Chay Hawk\Desktop\Random Number writing\main.cpp||In function 'int main()':|
C:\Users\Chay Hawk\Desktop\Random Number writing\main.cpp|21|error: no match for 'operator==' in 'type == X'|
||=== Build finished: 1 errors, 0 warnings ===|
change from string type; to int type;
http://www.cplusplus.com/doc/tutorial/basic_io/

Look for stringstream or be lazy and do what EssGeEich did. No offense Ess.
Topic archived. No new replies allowed.