Turbo C 2.0: Complete 2000-Word Guide to Installation, Configuration, Errors, I/O, Graphic
- Get link
- X
- Other Apps
Turbo C 2.0 is one of the classic and most influential C compilers used by programmers, students, and developers during the DOS era. Even today, many academic institutions still teach C programming using Turbo C because of its simple Integrated Development Environment (IDE) and easy-to-use tools. Although modern compilers are far more advanced, Turbo C remains an important learning tool for understanding the foundations of C programming.
This comprehensive guide answers the most common questions related to Turbo C 2.0—installation, configuration, compiler usage, linker errors, graphics handling, file I/O, memory issues, and more. Whether you are a beginner trying Turbo C for the first time or a student preparing for lab exams, this detailed blog post will help you solve every typical issue encountered.
1. Installing Turbo C 2.0
Before writing programs, Turbo C must be properly installed. The installation process is straightforward and uses an INSTALL program stored on the installation disk.
How to Install Turbo C
To begin installation:
-
Insert the Turbo C disk (INSTALL/HELP disk).
-
Change your active drive to the installation disk by typing:
A: -
Run the INSTALL program:
INSTALL -
Follow the on-screen menu prompts to choose:
-
Destination directory
-
Source drive
-
Installation options
-
Turbo C will automatically copy files, set up directories, and generate configuration files needed for both the Integrated Environment (TC.EXE) and command-line compiler (TCC.EXE).
2. Running Turbo C
Once installed successfully, running Turbo C is simple. From the DOS prompt, type:
TC
This starts the Integrated Development Environment (IDE) which includes:
-
Built-in editor
-
Compiler
-
Linker
-
Debugger.
Users can start writing code immediately, compile it, and test it inside the same environment.
3. Difference Between TC.EXE and TCC.EXE
Turbo C comes with two compilers, each designed for different purposes:
1. TC.EXE (Integrated Environment)
-
Full-screen editor
-
Built-in debugger
-
Integrated compiler and linker
-
Menu-driven interface
2. TCC.EXE (Command-line Compiler)
-
Faster, lightweight
-
Suitable for batch operations
-
No GUI
-
Requires manual use of makefiles, library paths, and switches
Both compilers use the same backend but differ in how users interact with them.
4. Configuration Files in Turbo C
Turbo C depends on configuration files to locate libraries, header files, and set default options.
Types of Configuration Files
-
TC.EXE uses:
TCCONFIG.TC -
TCC.EXE uses:
TURBOC.CFG
When INSTALL runs, it automatically creates TURBOC.CFG but embeds directory information directly into TC.EXE, so TCCONFIG.TC must be created manually.
Creating Configuration Files
For TC.EXE, run the IDE → adjust settings → press Alt + O + S to save options.
For TCC.EXE, edit the ASCII file TURBOC.CFG manually.
5. Integrated Environment (IDE) – Common Questions
Why Turbo C Can’t Find Header Files (#include)?
Header file search paths are defined under:
Options → Directories → Include Directories
If incorrect, update the path where .h files are located.
“Unable to open input file 'C0x.OBJ'” – Why?
The linker cannot locate startup and library files.
Fix it by updating:
Options → Directories → Library Directories
How to Use Multiple Source Files or Custom Libraries?
Turbo C includes a Project Manager that lets users group multiple .C files and link external libraries.
Use:
Project → Open Project
Graphics Library Functions Undefined
If using graphics, enable:
Options → Linker → Graphics Library → ON
or include GRAPHICS.LIB in your project file.
Why “Unable to open include file 'stdarg.h'”?
DOS has a limit on simultaneous open files.
Edit CONFIG.SYS and add:
FILES=20
Reboot the system afterward.
How to Change Colors in Turbo C Editor?
Use the utility:
TCINST.EXE
This allows color customization for menus, windows, and editor background.
How to Print the Program Code?
Press:
Shift + PrtSc
or use the editor command to print the current file or selected block.
MAKE Always Rebuilds the Project
If any file has a future date/time stamp, MAKE thinks it is outdated.
Use TOUCH.COM or correct the system clock.
6. Command-Line Compiler (TCC.EXE)
Include Files Not Found?
Use the -I option:
TCC -Ic:\turboc\include
Startup/Library Files Missing?
Use the -L option:
TCC -Lc:\turboc\lib
Graphics Library Undefined
Manually specify:
TCC BGIDEMO.C GRAPHICS.LIB
7. General Input/Output (I/O) Questions
Why Does cprintf() Not Move to Start of Line?
In Turbo C, \n is only line feed, not carriage return.
Use:
cprintf("\n\r");
How to Print to Printer from Turbo C Program?
Use stdprn:
fprintf(stdprn, "Hello printer!\n");
How to Read and Write Binary Files Correctly?
Always open file in binary mode using "rb" or "wb".
FILE *fp = fopen("data.bin", "rb");
Why printf() Doesn’t Print Color?
Use console I/O functions:
textcolor(RED);
cprintf("Colored text");
How to Print Long Integer or Long Double?
printf("%ld", l);
printf("%Lf", ld);
8. Example Programs & Compilation
Compiling MICROCALC
Refer to Appendix G of the Turbo C Reference Manual.
Compiling BGIDEMO
Steps:
-
Keep
.BGIand.CHRfiles in the same directory. -
Open BGIDEMO.C inside TC.
-
Press Ctrl + F9 to run.
9. Creating COM Files
Turbo C usually creates EXE files, but a COM file can be produced using:
tcc -mt -lt tinyfile
Limitations:
-
COM files support only Tiny memory model
-
Programs using floating point cannot be compiled into COM
10. Graphics Programming Questions
Why “BGI Error: graphics not initialized”?
initgraph() failed. Check the error:
int err = graphresult();
printf("%s", grapherrormsg(err));
11. Math & Floating Point Issues
Incorrect Results from cos(), tan() etc.?
Always include the math header:
#include <math.h>
Otherwise, Turbo C assumes the function returns int.
How to Trap Floating Point Errors?
Use:
-
signal()for runtime 8087/Emulator errors -
matherr()for library math errors
12. Linker Errors and Their Fixes
Undefined Symbol '_main'
Every C program must include:
void main() { }
or
int main() { }
Also ensure the file containing main() is part of the project.
Undefined Graphics Library Functions
Enable Graphics Library or manually include GRAPHICS.LIB.
Assembly Functions Undefined
Turbo C uses leading underscore for external symbols.
Assembly functions must be declared as:
_public _myfunc
13. Memory, Pointer & Stack Issues
Changing Stack Size
Add:
extern unsigned _stklen = 10000;
outside all functions.
Stack Overflow Solution
Use static for large local arrays:
static char bigarray[5000];
Null Pointer Assignment Error
Caused by:
-
Uninitialized pointers
-
Memory corruption
-
Overwriting memory
Why TC.EXE Creates Larger EXE Files?
Because debugging information is embedded by default.
Disable via:
Alt + D → S → N
Large Model Program Hangs with malloc()
Always include the correct header:
#include <alloc.h>
Pointer Crossing 64K Boundary
Use huge pointers.
Declaring Arrays Larger Than 64K
Must allocate from heap:
char (huge *arr)[128];
arr = farcalloc(1024, sizeof(*arr));
14. Turbo C with Other Languages
Using Assembly with Turbo C
Ensure:
-
Case sensitivity ON
-
Function names begin with
_ -
Correct segment declarations
Interfacing Turbo C with Turbo Pascal
Use:
-
CPASDEMO.PAS
-
CPASDEMO.C
Both included in EXAMPLES.ARC.
15. Turbo C and Clipper
Some versions may cause linking issues.
Developers should contact Nantucket Technical Support for Clipper-specific guidance.
Conclusion
Turbo C 2.0 remains a fundamental tool for understanding classic C programming, memory models, pointers, graphics, compiler behavior, and DOS-based application development. Despite being replaced by modern compilers, Turbo C teaches valuable low-level concepts that help students grasp how C works under the hood.
This guide provides solutions to every common Turbo C problem, making it easier to install, configure, compile, debug, and run C programs efficiently. Whether you're learning C for academics or exploring retro programming environments, Turbo C continues to serve as an excellent starting point.
Comments
Description: This exercise is an application of an array of structures/records
ReplyDeleteProblem: Make a program that will provide manipulation operations on an array of structures. It will have the following capabilities:
Input records
Display records
Record deposit
Record withdrawal
Delete a record
Implement the following design specifications:
Use the record of a bank account consisting of the following fields:
account number – this is a 6-digit whole number that distinguishes one deposit account from another
account name – this is the name of the depositor who owns the account and is a string of length 30
account balance – this is the amount left in the account
Create the following functions:
getData() – this will accept the fields from the user. Each record should be stored on the first element of the array, shifting the succeeding elements to shift to the right. There should be duplication in the account numbers.
showData() – this will display the fileds in tabular form
recordDeposit() – this will accept the account number and amount of deposit from the user, search for the account using a searching algorithm of your choice, and update the balance of the specified account
recordWithdrawal() – this will accept the account number and amount of withdrawal from the user, search for the account using the same linear search used in recordDeposit(), and update the balance of the specified account
deleteRecord() – this will accept the account number from the user, search for the account using the same linear search used in recordDeposit() and recordWithdrawal(), and deletes the specific account by shifting the remaining records to the left. The account number of the empty element should contain 000000.
The program should be menu-driven, that is, it should provide choices for the different capabilities. The menu could look like this:
BANK TRANSACTIONS MENU
1 -- Input deposit information
2 -- Display deposit information
3 -- Record deposit
4 -- Record withdrawal
5 -- Delete a Record
0 -- Exit
provide input validation
ReplyDeleteTHANK YOU FOR THE INFORMATION
PLEASE VISIT US
erp software providers