Bạn đang xem: Dev
We need khổng lồ modify one of the mặc định settings to lớn allow you to use the debugger with your programs. Go to the "Tools" menu & select "Compiler Options". In the "Settings" tab, click on "Linker" in the left panel, & change "Generate debugging information" khổng lồ "Yes": EXAMPLE: Multiple source files ![]() |
Xem thêm: Cách Tải Subway Surfers Trên Máy Tính, Pc Đơn Giản Nhất, Game Subway Surfers Online
Once you have entered all of your source code, you are ready lớn compile. Go lớn the "Execute" menu and select "Compile" (or just press CTRL+F9). It is likely that you will get some kind of compiler or linker error the first time you attempt khổng lồ compile a project. Syntax errors will be displayed in the "Compiler" tab at the bottom of the screen. You can double-click on any error khổng lồ take you to lớn the place in the source code where it occurred. The "Linker" tab will flash if there are any linker errors. Linker errors are generally the result of syntax errors not allowing one of the files khổng lồ compile. Once your project successfully compiles, the "Compile Progress" dialog box will have a status of "Done". At this point, you may click "Close". Step 5: Execute. You can now run your program. Go to the "Execute" menu, choose "Run". Note: khổng lồ pass command-line parameters to lớn your program, go lớn the "Execute" menu, choose "Parameters" và type in any paramaters you wish to pass. Disappearing windows If you execute your program (with or without parameters), you may notice something peculiar; a console window will pop up, flash some text and disappear. The problem is that, if directly executed, console program windows close after the program exits. You can solve this problem one of two ways: Method 1 - Adding one library call: On the line before the main"s return enter: system("Pause"); Method 2 - Scaffolding: showroom the following code before any return statement in main() or any exit() or abort() statement (in any function): /* Scaffolding code for testing purposes */ cin.ignore(256, " "); cout "Press ENTER khổng lồ continue..." cin.get(); /* end Scaffolding */ This will give you a chance to lớn view any output before the program terminates và the window closes. Method 3 - Command-prompt: Alternatively, instead of using Dev-C++ khổng lồ invoke your program, you can just mở cửa an MS-DOS Prompt, go to the directory where your program was compiled (i.e. Where you saved the project) and enter the program name (along with any parameters). The command-prompt window will not close when the program terminates. For what it"s worth, I use the command-line method. Step 6: Debug. When things aren"t happening the way you planned, a source-level debugger can be a great tool in determining what really is going on. Dev-C++"s basic debugger functions are controlled via the "Debug" tab at the bottom of the screen; more advanced functions are available in the "Debug" menu. Using the debugger: The various features of the debugger are pretty obvious. Click the "Run to cursor" icon to run your program & pause at the current source code cursor location; Click "Next Step" khổng lồ step through the code; Click "Add Watch" lớn monitor variables. Setting breakpoints is as easy as clicking in the black space next khổng lồ the line in the source code. See the Dev-C++ help topic "Debugging Your Program" for more information. Dev-C++ User F.A.Q. Why vị I keep getting errors about "cout", "cin", and "endl" being undeclared? It has to bởi vì with namespaces. You need to add the following line after the includes of your implementation (.cpp) files: using namespace std; How vì chưng I use the C++ string class? Again, it probably has to bởi with namespaces. First of all, make sure you "#include " (not string.h). Next, make sure you địa chỉ "using namespace std;" after your includes. Example: #include #include using namespace std; int main() string s; s = "This is a test"; cout "PAUSE"); return 0; That"s it for now. I am not a Dev-C++ expert by any means (in fact, I vì not teach C++ nor use it on a regular basis), but if you have any questions, feel không tính tiền to e-mail me at jaime