#include <iostream>
#include <ctime>
usingnamespace std;
void FuncTest(int x)
{
cout << "random number " << x << endl;
}
int main()
{
srand(time(NULL));
for (int i = 0; i < 25; i++)
{
cout << FuncTest(1+(rand() % 25)) << endl;
}
}
I'm getting this error
1 2
Warning 1 warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data c:\users\lastname\documents\visual studio 2013\projects\guessin_game\guessin_game\source.cpp 14 1 Guessin_Game
Error 2 error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion) c:\users\lastname\documents\visual studio 2013\projects\guessin_game\guessin_game\source.cpp 18 1 Guessin_Game
1 2
3 IntelliSense: no operator"<<" matches these operands
operand types are: std::ostream << void c:\Users\Lastname\Documents\Visual Studio 2013\Projects\Guessin_Game\Guessin_Game\Source.cpp 18 8 Guessin_Game
I also tried changing void FuncTest to int FuncTest and i get this error
1 2
Error 2 error C4716: 'FuncTest' : must return a value c:\users\lastname\documents\visual studio 2013\projects\guessin_game\guessin_game\source.cpp 9 1 Guessin_Game
Function FuncTest() was declared with a type of void, that is it does not return a value. Hence at line 18, the cout << is being asked to output something which isn't there.
As for the header file and the first warning, for completeness you should have #include <cstdlib> for the random functions, and you might put this at line 14 to avoid the warning C4244, srand( (unsignedint) time(NULL));