我正在编写一个程序来搜索一系列素数,大约一半来检查我的进度我决定建立它以确保一切正常工作好,我不断收到错误LNK2019!它说这是一个无法解决的外部因素。我做了一些研究,但我对其中的任何东西都不甚了解。这是代码。错误LNK2019 C++非常简单的程序
#include <iostream>
using namespace std;
int singlePrime(int subjectNumber);
int main() {
cout<<"Would you like to find a single prime number(1), or a range(2)?"<<endl;
int methodchoice;
cin>>methodchoice;
if(methodchoice ==1) {
int subjectNumber;
cout<<"Which number would you like to test for primeness?"<<endl;
cin>>subjectNumber;
int singlePrime(subjectNumber);
}
if(methodchoice==2) {
int lowRange;
int highRange;
cout<<"Input the low value for your range."<<endl;
cin>> lowRange;
cout<<"Input the high value for your range"<<endl;
cin>> highRange;
for (int index=lowRange; index<highRange;index++) {
if (index=highRange) {
break;
}
singlePrime(index);
}
}
}
从它'singlePrime'的外观。代码在哪里? – Thomas 2013-03-07 22:27:34
首先不要使用'使用命名空间std'在这里阅读更多关于为什么它的坏[链接]的详细信息(http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-a -bad - 实践 - 在-C)。然后,我觉得我必须提倡我为初学者程序员提供一个新的问答网站的建议。在哪里可以问初学者的问题和专家来到那里,因为然后想教而不是仅仅给出RTFM的答案。 http://area51.stackexchange.com/proposals/52242/beginner-programmers?referrer=YHFcRobXPDGfDpFmz1HCvA2 – AxelOmega 2013-03-07 22:29:15
建议:您开始使用大写字母的方法名称;将帮助你区分变量名称。 – 2013-03-07 22:29:17