http:^^www.cs.wisc.edu^~cs367-4^working^start.html

来自「This data set contains WWW-pages collect」· HTML 代码 · 共 113 行

HTML
113
字号
Date: Tue, 05 Nov 1996 20:57:53 GMTServer: NCSA/1.5Content-type: text/htmlLast-modified: Fri, 06 Sep 1996 19:01:56 GMTContent-length: 5194<HTML><!-- (c) 1996 Jim Skrentny   Permission is granted to use this document as you wish so long   as this restriction and the copyright notice remain untouched. --><HEAD><TITLE>Getting Started in CS367</TITLE></HEAD><BODY><CENTER><H2>Getting Started in CS367</H2></CENTER><P>I highly recommended that you immediately start learning the applicationsthat you will be using to develop your CS367 programs.  The environment inwhich you programmed in CS302 has differences than the one you'll use in CS367.Besides changing from the Macintosh or DOS/Windows operating system to UNIX,you'll also be working outside an integrated development environment.  Manyof the tools you've used before are still present, but as independentapplications.<P>Since you are reading this page I am assuming that you have successfullycreated your computer science account using <CODE> newuser </CODE> and are nowlogged in.  The following exercise takes you through the steps to get your firstC++ program compiled and running under UNIX.  I have provided a sample programthat plays the game <I>tic-tac-toe</I> for your use and experimentation.<P>While working on this exercise, you will be reading pages that indicateUNIX commands to enter.  These commands are preceded by a <CODE> % </CODE>,which it represents the UNIX prompt. You should not enter the <CODE> % </CODE>.<P>First, in your private sub-directory create a directory named <I>P0</I>(i.e. Pzero). If you are unfamiliar with how to do this see the page on<!WA0><!WA0><!WA0><!WA0><A HREF="http://www.cs.wisc.edu/~cs367-4/working/mkdir.html">how to create a directory</A>.  Next get a copy ofthe sample tic-tac-toe program. This sample program can be obtained fromthe samples page that is linked to the CS367 home page.  During the semesterI will be providing sample code for data structures that we discuss in lecture.Find this link by going back to the CS367 home page and looking for the samplepage link.  If you are having difficulties, <!WA1><!WA1><!WA1><!WA1><A HREF="http://www.cs.wisc.edu/~cs367-4/samples.html">clickhere</A> to go directly to that page.  Further instructions are provided inthe samples page for getting a copy of sample code files such as for this casetictactoe.cc.<P>Now that you have a copy of the source file for the tic-tac-toe gameyou should look at it with and editor.  See <!WA2><!WA2><!WA2><!WA2><A HREF="http://www.cs.wisc.edu/~cs367-4/working/edit.html">edit yourprogram</A> for more information on how to edit your program.  You do notneed to make any changes to compile the program, which will be the nextstep.  Before compiling the program I suggest that you open another terminalwindow.  This can be done by clicking the left mouse button anywhere on thebackground and selecting Xterm from the pop-up menu.  More information aboutthe X-window system is available <!WA3><!WA3><!WA3><!WA3><A HREF ="http://www.cs.wisc.edu/csl/cs1000/node7.html#SECTION00340000000000000000">here</A>.This new xterm window will be used for compiling your program.  Changedirectories to the location where you have copied the source code by entering:<PRE>	% cd private/P0</PRE><P>You may compile your program by entering the g++ compiler command below.This command assumes that the source file is named tictactoe.cc.<PRE>       % g++ -Wall -g -o tictactoe tictactoe.cc</PRE>For more information about the compiler flags see <!WA4><!WA4><!WA4><!WA4><A HREF="http://www.cs.wisc.edu/~cs367-4/working/compile.html#flags">the page on compiler flags</A>.<P>When you are developing your own programs you usually encounter compilationerrors.  These are typically syntax errors that prevent the compiler fromcreating an executable version of your program.  In this case you would needto go to your editor window and make corrections to your source code.  For thisprogram you should not experience any compiler errors, unless you accidentallychanged the source with the editor.  In that case you can simply get a newcopy of this sample code.<P>The next step after your program compiles would be to run your program.This is doen by entering the following at the UNIX shell prompt:<PRE>       % tictactoe</PRE>More information about running programs is located<!WA5><!WA5><!WA5><!WA5><A HREF="http://www.cs.wisc.edu/~cs367-4/working/run.html">here</A>. While developing programs it is prefered to runyour program in a debugging environment.  In UNIX this requires you to executeanother application as shown below.<PRE>       % gdb tictactoe</PRE>This start the debugger and allows you to control the execution of yourprogram with breakpoints and by stepping through the program's instructions,and to examine the contents of variables and other memory locations.  Twoimportant commands for the debugger are run, which begins execution ofyou program, and quit to end the debugger.  The are many other commands andsome of the most useful are described <!WA6><!WA6><!WA6><!WA6><A HREF = "http://www.cs.wisc.edu/~cs367-4/working/commands.html">here</A>.<P>What you have completed above is called program development cycle: edit,compile, debug, repeat until it works.  However I have made a working programfor you, which simplifies the process a great deal.  More information aboutthe program development cycle can be obtained from the<!WA7><!WA7><!WA7><!WA7><A HREF = "http://www.cs.wisc.edu/~cs367-4/working/working.html">Working with C++ in UNIX</A> page.  Real practice isobtained by writing and debugging your own C++ program.  See<!WA8><!WA8><!WA8><!WA8><A HREF = "http://www.cs.wisc.edu/~cs367-4/program0.html">program 0</A> for more information.</BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?