Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

compiler/callfunction

Name: Anonymous 2010-11-05 22:55

Hurr, getting into the basics of C++ here, and running into issues with calling user defined functions more often that I feel I should. I wrote a mock program to test the issue, and I'm still running into trouble:

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iomanip>

using namespace std;
int randGen ();

int main ()
{
    srand ( time ( 0 ) );
    cout << randGen;
    cin.ignore().get();
    return EXIT_SUCCESS;
}

int randGen ()
{
    srand ( time ( 0 ) );
    return ( 1 + rand ( ) % 10);
}

It compiles, but it tells me "[Warning] the address of `int randGen()', will always evaluate as `true' " and the only thing it outputs is "1" when I want it to output a random number between 1 and 10.

help?

Name: Anonymous 2010-11-06 21:39

>>18
an array of 30 random numbers shouldn't all be the same number. and a rerun of the program will result in a different number than the initial run but all 30 outputs will be the same number.

that's not random, there's some flaw in the way the program is grabbing the numbers.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List