Presentation is loading. Please wait.

Presentation is loading. Please wait.

簡易 Visual Studio 2005 C++ 使用手冊

Similar presentations


Presentation on theme: "簡易 Visual Studio 2005 C++ 使用手冊"— Presentation transcript:

1 簡易 Visual Studio 2005 C++ 使用手冊
Han-Chern Ling

2 下載 Visual Studio 2005 中文版 利用瀏覽器IE進入學校計算機網路中心 http://www.cc.ncku.edu.tw
點選校園授權軟體,或 進入『Visual Studio 系列』,其中有許多版本,請下載 『Visual Studio 2005 中文版』,共有三張光碟影像檔;若只裝C++語言的話,只需Visual Studio 2005 Disk 01 及 Disk 02 兩張即可。 將影像檔燒成光碟,或利用下頁所述利用虛擬光碟軟體影像檔載入到虛擬光碟機。

3 下載虛擬光碟機 Daemon Tools 利用瀏覽器IE進入Daemon Tools 首頁 download 進入下載專區; 下載 『DAEMON Tools Lite 』。

4 下載虛擬光碟機 MagicISO Virtual Disk
另外也可使用 MagicISO Virtual CD/DVD-ROM Disk 虛擬光碟機來安裝光碟。 MagicISO Virtual CD/DVD-ROM Disk 可在 下載

5 安裝虛擬光碟機 Daemon Tools 在剛下載下來的 DAEMON Tool 安裝軟體上點兩下,進行安裝;安裝時,它會要求重新開機,就重新開機後繼續安裝; 預設它會同時在 IE 上安裝 『Daemon Tool Search Bar』 ,如果不想改變你的 IE 形貌,請把該部分的選項取消,安裝時如果軟體會再次要求安裝 Search Bar 時,請按 『decline』按鈕。 安裝完後須重新開機,就再重新開機。 重開機後,會在『我的電腦』中出現一個虛擬光碟機,並在右下角出現一個類似閃電符號的虛擬光碟機的常駐軟體圖像; 這時可用右鍵點選該圖像,並將下載回來的 Visual Studio 2005 光碟檔利用 Mount image 載入虛擬光碟機,進行安裝Visual Studio 2005。

6 建立、編譯、執行 C 程式 三個方式: 進入Visual Studio 2005 或Visual C++ 後,先建立專案
在 DOS 視窗中執行 cl xxx.c /W4 在視窗中直接點選 C 程式碼(僅適用於 Visual C++ 6的版本)

7 在Studio 2005 中建置新的 Project (專案) - I
在 Studio 2005 中必須先建立程式之 Project 後,才可進行後續的編譯程式與執行,故在此先進行建立 Project : 進入Visual C 後 檔案  新增  專案; 出現『新增專案視窗』後,選取『一般』『空專案』; 選取本project 存取位置後,在名稱處填入專案名稱; 按確定後,這就建好ㄧ個新的專案了。

8 在Studio 2005 中建置新的 Project (專案) - II
接下來,就要建立新的 C 或 C++ 的程式碼(source code),或將已建好的 source code 加入專案中 : 建立新的 C 或 C++ 的程式碼 方案總管(滑鼠右鍵)  原始程式檔 加入  新增項目; 出現『加入新項目』  程式碼  C++檔  加入名稱(如果是C的程式檔,請用副檔名 .c,否則預設副檔名是 .cpp)  加入; 這時就可在新視窗鍵入你的程式碼。 開啟已建立的 C 或 C++ 的程式碼 方案總管(滑鼠右鍵)  原始程式檔 加入  現有項目

9 在Studio 2005 中編譯及執行 Project (專案) - III
程式碼完成後,就可建立執行檔了: 建置  建置方案 (or Press F7)  希望編譯時沒有出現錯誤 偵錯  啟動但不偵錯 (or Press ctrl+F5)

10 方法二:直接在 DOS 視窗下、下指令碼 \> cl source.c /W
如果安裝的是 Visual Studio 2005 的版本,請用該版本專用的命令提示字元(在開始  Microsoft Visual Studio 2005  Visual Studio Tools  Visual Studio 2005 命令提示字元),不要使用附屬應用程式下的命令提示字元。你可將該『Visual Studio 2005 命令提示字元』複製到桌面。 方便、簡潔;但Debugging ? 需預先利用 Text Editor (如記事本) 編輯程式

11 在VC 6 中建置新的 Project (專案) - I
若使用第四版教科書所附光碟建立編輯環境的話,就會在電腦上安裝 Microsoft Visual C++ 6 的環境。同樣的,在 VC6 中須先建立程式之 Project 後,才可進行後續之編譯與執行之動作,故在此先進行建立 Project : 進入MS Visual C++ 後 New 出現New 視窗後選Win32 Console Application 選取本project 存取位置後,填入project 名稱 按Ok後,選取An Empty Project 按 Finish, 這就建好ㄧ個新的專案了

12 在VC 6 中建置新的 Project (專案) - II
接下來,就要建立新的 C 或 C++ 的程式碼(source code),或將已建好的 source code 加入專案中 : 建立新的 C 或 C++ 的程式碼 Project  Add to Project  New  C++ Source File  Input File Name  Press “OK” 開啟已建立的 C 或 C++ 的程式碼 Project  Add to Project  Files  Open File  Press “OK”

13 在VC 6 中編譯及執行 Project (專案) - III
接下來,就可建立執行檔了: Build  Build Test.exe (or Press F7)  希望編譯時沒有出現錯誤 Execute Test.exe (or Press ctrl+F5)

14 方法三:直接點選 C 程式碼 本法只適用於 Visual C++ 6 版本,在Studio 2005 中並不適合使用。在 VC 6 環境下,也可在window 視窗利用直接點選 C 程式碼的方法進行編譯與執行:

15 Oops! 錯誤產生時,該怎麼辦? Syntax Errors (語法錯誤) – When compiler can not recognize a statement If an error message appears in the Output pane’s Build tab, double-clicking anywhere on the error message displays the source file and places a blue arrow marker in the margin indicator bar (i.e., the gray strip to the left of the source code), indicating the offending line. If you do not understand the error message, highlight the error message number by dragging the mouse over the number, then press the F1 key. This displays a help file that provides information about the error and some helpful hints as to the cause of the error.

16 Debugging Run-Time Logic Errors (語意錯誤)
The Visual Studio provides a debugger tool to help the programmer find run-time logic errors in programs that compile and link successfully but do not produce expected results. The debugger lets the programmer view the executing program and its data as the program runs either one step at a time or at full speed. The program stops on a selected line of code or upon a fatal run-time error. To use the debugger, set one or more breakpoints by clicking the line in the program where the breakpoint is to be placed and clicking the Insert/Remove Breakpoint button in the Build MiniBar or by pressing the F9 key.

17 Debugging Run-Time Logic Errors
The Visual Studio provides a debugger tool to help the programmer find run-time logic errors in programs that compile and link successfully but do not produce expected results. The debugger lets the programmer view the executing program and its data as the program runs either one step at a time or at full speed. The program stops on a selected line of code or upon a fatal run-time error. To use the debugger, set one or more breakpoints by clicking the line in the program where the breakpoint is to be placed and clicking the Insert/Remove Breakpoint button in the Build MiniBar or by pressing the F9 key.

18 Debugging You may need to manually switch between the IDE and the console window to perform input. To switch between windows you can use Alt + Tab or click your program’s panel on the Windows taskbar at the bottom of the screen. The yellow arrow to the left of a statement indicates that execution is suspended at this line. This statement will be the next statement executed.


Download ppt "簡易 Visual Studio 2005 C++ 使用手冊"

Similar presentations


Ads by Google