I making a simple single number scrambler/encryptor and as I tried to build the console application the following error
occurred:
error: invalid operands of types 'void' and 'int' to binary 'operator%'
I have no idea what this means. The source code is bellow.
I am running code::blocks as my IDE on Ubuntu.
Thank you for any help!
occurred:
error: invalid operands of types 'void' and 'int' to binary 'operator%'
I have no idea what this means. The source code is bellow.
Code:
#include <iostream>
#include <math.h>
#include <cstdlib>
using namespace std;
int main()
{
int nTimer;
int nInput;
int nRand;
int nInRa;
nTimer = 0;
nRand = 1;
nInRa = 0;
cout << "Input a number" << endl;
cin >> nInput;
while(nTimer < 5){
nInRa = srand(nRand)% 3 + 1;//error is on this line
if(nInRa == 1){
nInput = nInput + 1;
}
if(nInRa == 2){
nInput = nInput + 2;
}
if(nInRa == 3){
nInput = nInput + 3;
}
nTimer = nTimer + 1;
nRand = nRand + 1;
}
cout << nInput;
return 0;
}
Thank you for any help!
Comment