[問題] 同一個專案兩個程式的問題?
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
visual studio 2010
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
1>------ 已開始建置: 專案: learn5, 組態: Debug Win32 ------
1>已經開始建置於 2013/11/2 下午 04:25:44。
1>InitializeBuildStatus:
1> 由於指定了 "AlwaysCreate",因此正在建立 "Debug\learn5.unsuccessfulbuild"。
1>ClCompile:
1> learn6.cpp
1>ManifestResourceCompile:
1> 所有輸出都是最新的。
1>learn6.obj : error LNK2005: _main 已在 learn5.obj 中定義過了
1>c:\users\user\documents\visual studio 2010\Projects\learn5\Debug\learn5.exe
: fatal error LNK1169: 找到有一或多個已定義的符號
1>
1>建置失敗。
1>
1>經過時間 00:00:00.99
========== 建置: 0 成功、1 失敗、0 最新、0 略過 ==========
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <iostream>
using namespace std;
int main()
{
char* pstr1="Robert Redford";
char* pstr2="Hopalong Cassidy";
char* pstr3="Lassie";
char* pstr4="Slim Pickens";
char* pstr5="Boris Karloff";
char* pstr6="Oliver Hardy";
char* pstr="Your lucky star is";
int dice=0;
cout << endl
<< "Pick a lucky star!"
<< "Enter a number between 1 and 6:";
cin >> dice;
cout << endl;
switch(dice)
{
case 1:cout << pstr << pstr1;
break;
case 2:cout << pstr << pstr2;
break;
case 3:cout << pstr << pstr3;
break;
case 4:cout << pstr << pstr4;
break;
case 5:cout << pstr << pstr5;
break;
case 6:cout << pstr << pstr6;
break;
default:cout << "Sorry,you haven`t got a lucky star.";
}
cout << endl;
return 0;
}
補充說明(Supplement):
我開一個專案然後寫一個程式沒問題,但是第一個程式專案執行沒問題?但是如果寫第二
個程式就會有上面的問題?請問一下是因為一個專案裡面只能有一個main()的關係嗎?那這
樣我的別的程式不就一定要寫在別的專案內?我以為一個專案就可以當一個系統,請各
位高手指教?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.143.241.61
※ 編輯: joinbee 來自: 220.143.241.61 (11/02 16:39)
※ 編輯: joinbee 來自: 220.143.241.61 (11/02 17:12)
※ 編輯: joinbee 來自: 220.143.241.61 (11/02 17:19)
推
11/02 17:56, , 1F
11/02 17:56, 1F
→
11/02 17:56, , 2F
11/02 17:56, 2F
→
11/02 17:57, , 3F
11/02 17:57, 3F
推
11/03 20:39, , 4F
11/03 20:39, 4F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章