当尝试调试isPrime程序时,我开始遇到警告,该警告不允许我运行该程序。警告状态为Relocation truncated to fit: R_X86_64PC32 against undefined symbol "isPrime(int)"
。我前一段时间遇到了这个问题,但此后却完全忘记了如何处理它。是通常导致此问题的程序出现问题,还是netbeans及其用于C的编译器出现了问题。
#include <stdio.h>
#include <stdbool.h>
bool isPrime(int userInput);
int main(int argc, char** argv)
{
int userInput;
bool prime = false;
int again = 0;
printf("This program will check if a number is Prime\n");
while(again == 0)
{
printf(" Enter number: \n ");
scanf("%d",&userInput);
prime = isPrime(userInput);
if( prime )
printf("%d is prime.",userInput);
else
printf("%d is not prime",userInput);
printf("again? \n 0 for yes \n 1 for no");
scanf("%d", &again);
}
return 0;
}
bool isPrime(int userInput)
{
int tmp = 0;
bool result = true;
while(tmp != 1 && result == true)
{
if( userInput % tmp == 0)
result = false;
tmp--;
}
return true;
}
\
代码已编辑