我正在編寫一個程序來搜索一系列素數,大約一半來檢查我的進度我決定建立它以確保一切正常工作好,我不斷收到錯誤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