vendredi 3 mars 2017

"Error LNK2019: unresolved external symbol" / random generator

The exact error message says: "error LNK2019: unresolved external symbol "int * __cdecl getEvenRandomNumber(void)" (?getEvenRandomNumber@@YAPAHXZ) referenced in function _main"

I've tried changing the code around, but nothing i do fixes it. ultimately, im just not really sure whats the problem, and what the error is saying.

Heres my some of my code where i think the problem might be:

int* getEvenRandomNumber();
bool isPrime(int n);
void findPrimeNumberTargets(int max, int& a1, int& a2);

int main(int argc, char** argv) 
{

    int *RandNo = getEvenRandomNumber();
    cout << "Even Random Number Greater than Two:" << *RandNo;
    int a1,a2;
    a1=2;
    a2 = *RandNo -a1;

    findPrimeNumberTargets(*RandNo, a1, a2);

    cout << "Prime Numbers " << a1 << " and " << a2 << " add up to "<< *RandNo;

    delete RandNo;
    return 0;
}



int* getEvenRandomNumber()
{
    int *myRand = new int;
    bool isEven =false;

    srand (time(NULL));

/* generate even random number */
    while( !isEven)
    {
        *myRand = rand();
        if(((*myRand %2 )==0)&&(*myRand > 2))
            isEven = true;
    }
    return myRand;
}




Aucun commentaire:

Enregistrer un commentaire