Error: Undefined Reference to Function

Asked

Viewed 25 times

-2

#include <iostream>
#include <stdlib.h>
#include <windows.h> // textcolor
#include <conio.h>


using namespace std;

bool verifiva_primo(int n);

int main(){
    setlocale(LC_ALL, "Portuguese");
    bool res;
    int num;
    cout << "Insira um número inteiro maior que 1: ";
    cin >> num;
// clrscr(); não funciona no GCC
    res = verifiva_primo(num);

    if(res == true)
        cout << "O número " << num << " é primo!!\n";
    else{
        cout << "O número " << num << " não é primo!!\n";
}

    return 0;
}

bool verifica_primo(int n){
    int divide=0;
    for(int i=1; i<=n; i++){
        if(n % i == 0){
            divide++;
            break;
        }
    }
    if(divide>2){
        return true;
    }
    else{
        return false;
    }
}

Someone can see what’s wrong, I’ve never had this error before, in codeblocks only shows: Ld returned 1 Exit status

1 answer

0


You have declared the function as verifica_primo, but you are referencing it and calling it as verifiva_primo. It is just a typo.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.