[Help] Why doesnt this work?

Had a hard time getting this to work when I think it should be easy.. guess im just that bad.

The code try to generate 7 numbers and a number cant be genereted twice. That way it should be. But What am i doing wrong?


#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main()
{
int lottorad[7];
bool lika=false;
srand(time(0));
for(int i=0; i<7; i++)
{
lottorad[i]=rand()%35+1;

for(int j=0; j<i; j++)
{
if(lottorad[i]=lottorad[j])
lika=true;
}
if(lika=true)
{
i--;
lika=false;
}
else
cout << lottorad[i] << endl;
}
return 0;

}
Both of your two "if" statements use = when they should use ==

(But it took me an embarassingly long time to find that!)
Thank you kind sir
Topic archived. No new replies allowed.