banner



How To Open C Program In Windows Xp



An Intro to C/C++ Programming

Copyright©2004 past Daniel B. Sedory


  • Uncomplicated Console Lawmaking Examples
    • How to get the Microsoft® "Command Prompt Hither" Powertoy.
    • Using Borland's Turbo Debugger
    • Some other C instance: CHARTYPE.C

A Simple Console Program Example
(with instructions):

A very simple Console program, Simply.exe: SimplyC.nix [with the "C" source code and my MAKEsimply.cmd Batch file; Notation: This .CMD "Make" file (equally we're calling it) has nada to do with Borland'due south Brand program and its own makefilesouthward! We will, however, be commenting on those later.] Here's a screenshot of what the .CMD (Batch) program will brandish when compiling and linking   but.c into simply.exe (the program):

Edifice but.exe ...

Borland C++ 5.5 for Win32 Copyright (c) 1993, 2000 Borland
simply.c:
Turbo Incremental Link five.00 Copyright (c) 1997, 2000 Borland

Link Successful; you even so need to examination your plan!

Press whatsoever key to continue . . .

If all goes well, but press a key and the window disappears! At present get ahead and try it yourself! When you look in whatever folder y'all made for the program files (e.chiliad., C:\bc55\examination\simply\ ) you should now come across the following files:

MAKEsimply.cmd
merely.c
just.exe
simply.map
simply.obj
simply.tds

  1,241 bytes
948 bytes
53,760 bytes
276 bytes
1,615 bytes
393,216
bytes

Y'all started with only the first 2 files listed in a higher place. The .obj file was created past the compiler ( bcc32 ) from the .c file, and the .exe file (the plan) was created by the linker ( ilink32 ). The Map file is a unproblematic table that shows where a few general parts (similar the code and information sections) can be institute in the executable; you can keep a Map file from existence created by adding a /x to the end of the linker line in my Cmd make plan!

When you run but.exe (you'll need to open a Control Prompt window first), its output should look like this:

Panel Programs for Windows 2000/XP/2003 tin can
exist as simple every bit these 'C' Source lines:

*****************************************************************
#include <stdio.h>

main()
{
printf ("\north\n");
printf (" Panel Programs for Windows 2000/XP/2003 can\due north");
printf (" be as unproblematic equally these 'C' source lines:\n\n");

return(0);
}
*****************************************************************

If the plan'due south "C" source code is completely strange to you, I recommend that yous nonetheless try to work through this page and compile the programs. One time you outset reading Bruce Eckel's gratis book, Thinking in C++ (which includes a chapter on C coding), you'll be able to return hither for a quick review in society to compile/link the examples in his book.

The .tds file (past far the largest 1) is always created by the Borland linker; whether you demand it or not. Information technology contains most of the data necessary to debug the program, merely will be unable to do and so unless the proper switches * are prepare for both the compiler and the linker!  In our Cmd make file for Simply, we asked both the compiler (using the -5 switch) and the linker (using /5 ) to add debug data to its .tds file; allowing us to debug the plan in Borland's Turbo Debugger for Windows.Depending upon which command-line has the "v" switch missing, TD32 will show a couple different error messages. As an exercise, you should get through the brand process: 1) offset without ane switch, two) only without the other and then iii) without both of them to see how TD32 acts when y'all effort to debug simply.exe!
_____________
* You tin can discover very detailed information most every switch and option for both the compiler and linker in the HELP file, bcb5tool.hlp, constitute in your C:\bc55\Assistance\ folder!

Using Borland's Turbo Debugger

Inbound td32 simply.exe at the Control-line prompt for your Just examination folder, will change the window into something like this:

And if you wait at the Os's TASKBAR, you should come across that yet another window has opened up! The second window is for showing the output of the programme while debugging it. If you lot have an 800x600 (or larger) display setting, you should be able to run into most if not all of both windows at the same fourth dimension! At present look for a piddling yellow arrowhead along the left-side of the first window (there's a red circle around it in the picture show above). That shows which line of source code is well-nigh to be executed. Pressing the F7 key will execute ane line of code and accelerate the little arrow down 1 line each time y'all press F7; only information technology will skip any lines that do non have a thick yellow dot on them. Printing F7 twice and so look at the second window. It should now look similar this:

If you continue pressing the F7 key, y'all'll end up running through the whole program; after executing any code that ends the program, the second window volition disappear. And so you'll see a bulletin box that states, "Process terminated." Press the ENTER central (or click on the OK button in full-screen), to remove the message box.
{ NOTE: If you lot press the ALT plus ENTER keys while this window is in focus, it will become full-screen , and you lot'll be able to utilise the mouse (with a rectangular-shaped cursor). }
If you open the " R un" menu and select " Program reset" or simply press the CTRL plus F2 keys, y'all'll be able to debug the program again without having to quit TD32. Go ahead and practice that now.
Although Turbo Debugger has its own built-in Help, it's a flake more than difficult to notice answers in it than in a Windows Help file. Select " Help on aid" from the " Help" carte du jour and note the keys that volition aid you navigate through the Assistance panes; while there, select the topic "Breakpoints" and learn how to fix a breakpoint on one of the code lines. Unless you change information technology, a simple breakpoint defaults to the "action" of break and the "condition" of ever. At present set a breakpoint on one of the code lines and " Run" the plan by pressing the F9 primal! The programme should halt before executing the instruction on that line. Yous tin Quit Turbo Debugger at any time by pressing the ALT plus X keys!

CHARTYPE.C

Here's some other little C program which lists all 256 of the ASCII characters in Hex and Decimal: CHARTYPE (.cipher; 37KB) with a pre-compiled 32-bit version that's been compressed by UPX.

Practise: Make a copy of the file MAKEsimply.cmd from above and change the file proper noun to: MAKEchartype.cmd . Replace each occurance of the word "simply" (5 of them) in this new file with "chartype" then execute it in a separate directory containing the file chartype.c. If you lot see a message stating: "Alert W8080 CHARTYPE.C 172: '_getch()' is alleged but never used" don't worry about information technology; that'due south because the program never uses a character from the "getch()" function. Information technology's but a tricky (and perhaps sloppy) way nosotros used to get the program to wait until a primal is pressed. You should ever search the Cyberspace and forums for the best manner to carry out a process when writing a program for a customer.

After checking the new executable (its size should be 58,368 bytes), run the program under Turbo Debugger. If you tin, make sure to place both windows on your Desktop in a mode that allows you to meet the plan output while running the debugger!

During its execution (using the F7 key), you'll go an idea of how the plan operates. Make certain yous trace through (F7) each of the plan's defined functions [dispchars() and lastline()] then you can see how a office (subroutine) tin save both space and a lot of time coding. And so utilise the F8 key to step over * [execute each function without leaving the main() program sequence] them.

Note: It's possible to change the code in CHARTYPE and so that it will merely recognize a single type of keypress (such as the ENTER key) before continuing. Little routines such as that are the kind of code you'll use over and over again and may even add to a library of functions you'll utilise for a big projection.

_______________
*
In Microsoft'southward DEBUG.EXE program, the "t" or "p" keys are used respectively to trace through ( step into ) or proceed ( step over ) any subroutines in the Assembly lawmaking. It'due south my opinion that Borland's decision to utilize the word "Step" side by side to the F8 key on the bottom of the brandish window might confuse some students!



Last Update: 27 March 2004.

Dorsum to The Starman'due south Realm Index page!

Source: https://thestarman.pcministry.com/C/L1.htm

Posted by: mccoypaten1955.blogspot.com

0 Response to "How To Open C Program In Windows Xp"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel