TURBO C 2.0: ANSWERS TO COMMON QUESTIONS Getting started Q. How do i install Turbo C? A. Run the INSTALL program from the INSTALL/ helP disk. To start the installation, change your current drive to the one that has the install program on it and type INSTAll. You will be given instructions in a box at the bottom of the screen for each prompt. For example, if you will be installing from drive a: type INSTALL At this point, the INSTALL program will appear with menus selections and descriptions to guide you through the installation process. Q. How do i run Turbo C? A. After you have installed Turbo C, type tc from the dOs prompt and you re ready to go. Chapter 2(Getting Started) of the Turbo C User s Guide will guide you through your first Turbo C program Q. What is the difference between TC. eXe and TCC. eXE? A. The Turbo C package comes with two compilers, an Integrated Environment named TC. eXE and a command-line compiler named TCC. EXE. The Integrated Environment is essentially the command-line compiler with an integrated editor, linker, and debugger Please refer to the Turbo C Users Guide for details on using both systems Q. What is a configuration file? A. A configuration file tells Turbo C what options to default to and where to look for its library and header files. TC. EXE looks for a configuration file named TCCONFIG. TC, and TCC. eXe looks for a file named TURBoC. CFG. See the users Guide, pages 40 and 143 for more information. Q. How do I create a configuration file? A. When you run the INSTALL program it creates a configuration
TURBO C 2.0: ANSWERS TO COMMON QUESTIONS G e t t i n g S t a r t e d --------------------------------------------------------------------- - Q. How do I install Turbo C? A. Run the INSTALL program from the INSTALL/HELP disk. To start the installation, change your current drive to the one that has the install program on it and type INSTALL. You will be given instructions in a box at the bottom of the screen for each prompt. For example, if you will be installing from drive A:, type: A: INSTALL At this point, the INSTALL program will appear with menus selections and descriptions to guide you through the installation process. Q. How do I run Turbo C? A. After you have installed Turbo C, type "TC" from the DOS prompt and you're ready to go. Chapter 2 (Getting Started) of the Turbo C User's Guide will guide you through your first Turbo C program. Q. What is the difference between TC.EXE and TCC.EXE? A. The Turbo C package comes with two compilers, an Integrated Environment named TC.EXE and a command-line compiler named TCC.EXE. The Integrated Environment is essentially the command-line compiler with an integrated editor, linker, and debugger. Please refer to the Turbo C User's Guide for details on using both systems. Q. What is a configuration file? A. A configuration file tells Turbo C what options to default to and where to look for its library and header files. TC.EXE looks for a configuration file named TCCONFIG.TC, and TCC.EXE looks for a file named TURBOC.CFG. See the User's Guide, pages 40 and 143 for more information. Q. How do I create a configuration file? A. When you run the INSTALL program it creates a configuration
file named TURBOC. CFG for TCC. EXE. This file is just an ASCII file which you can change with any text editor. It contains the path information for the library and header files for TCC. eXe to use. The INSTALL program does not create a tcconFiG. tc file for tc. exe because it installs the directory information directly into TC. EXE. You can create a setting your options however you want to set them, and typing alt-O/S Integrate Environment Q. Why is Turbo C not able to find any of my #include files? A. The compiler searches for include files in the Turbo C Include Directories. This option is specified under the Options/ Directories menu. The INStalL program initially sets this option to the directory where it copied all the turbo C *. h files. Q. Why do i get the message Linker Error: Unable to open input file COx. OB A. The linker searches for Turbo C start-up and library files in the Turbo C Library Directories. This option is specified under the Options/Directories menu. The INSTall program initially sets th option to a directory where it copied the start-up and library files Q. How do i get Turbo c to link in my own libraries or use multiple A. Turbo C s Project facility is designed to allow you to work with multiple files. Refer to Chapter 3 of the turbo C User s Guide under Projects: Using Multiple Source Programs Q. Why does the linker tell me that all the graphics library routines are undefined? A. The Options/ Linker/ Graphics Library item must be set on, if you are using any Turbo c graphics functions and have not specifyed GRAPHICS LiB in a project file Q. Why does Turbo C report Unable to open include file stdarg. h
file named TURBOC.CFG for TCC.EXE. This file is just an ASCII file which you can change with any text editor. It contains the path information for the library and header files for TCC.EXE to use. The INSTALL program does not create a TCCONFIG.TC file for TC.EXE because it installs the directory information directly into TC.EXE. You can create a configuration file for TC.EXE by running TC, setting your options however you want to set them, and typing Alt-O/S. I n t e g r a t e d E n v i r o n m e n t --------------------------------------------------------------------- - Q. Why is Turbo C not able to find any of my #include files? A. The compiler searches for include files in the Turbo C Include Directories. This option is specified under the Options/Directories menu. The INSTALL program initially sets this option to the directory where it copied all the Turbo C *.h files. Q. Why do I get the message: Linker Error: Unable to open input file 'C0x.OBJ' A. The linker searches for Turbo C start-up and library files in the Turbo C Library Directories. This option is specified under the Options/Directories menu. The INSTALL program initially sets this option to a directory where it copied the start-up and library files. Q. How do I get Turbo C to link in my own libraries or use multiple source files? A. Turbo C's Project facility is designed to allow you to work with multiple files. Refer to Chapter 3 of the Turbo C User's Guide, under "Projects: Using Multiple Source Programs". Q. Why does the linker tell me that all the graphics library routines are undefined? A. The Options/Linker/Graphics Library item must be set ON, if you are using any Turbo C graphics functions and have not specifyed GRAPHICS.LIB in a project file. Q. Why does Turbo C report "Unable to open include file 'stdarg.h
when I try to #include <stdio. h>? A. The most probable reason is that you have exceeded the number of files that dos can have open simultaneously. Add the line FILES= to your DOS CONFIG. sys file. This allows dos to open up to 20 files at the same time. CONFIG. sys will only be effective after you have rebooted your computer. See the IBM DOS Reference Manual for details on the config. sys file Q. How do i change the colors of the editor and menus in TC? A. The utility TCINst eXe allows you to customize your colors. Q. How do i get a listing of my source code to my printer? A. From within the turbo C editor hit <Ctrl>k<P>. This will print a marked block to the printer If no block is marked this key sequence will print the entire file in your editor Q. When I Make, Run, or Trace a program Turbo C sometimes goes through the compile and link process even when the object files A. Turbo C s mAKe logic works solely on a files date and time file marked with a date thats sometime in the future, the ob ject files that are reated from it will always be older than the source file and Turbo C will always try to rebuild the file. You can fix this by using TOUCH. Com to set the file to the current date and time. You should also make sure that your systems date and time are always properly set Comma nd -line compile r Q. Why is turbo C not able to find any of my #include files? A. The compiler searches for include files in the Turbo C Include Directories. This option is specified by the -I switch. The INSTALL rogram initially writes a configuration file(TURBoC. CFG)that sets this to the directory where it copied all the turbo C * h files
when I try to #include <stdio.h>? A. The most probable reason is that you have exceeded the number of files that DOS can have open simultaneously. Add the line FILES=20 to your DOS CONFIG.SYS file. This allows DOS to open up to 20 files at the same time. CONFIG.SYS will only be effective after you have rebooted your computer. See the IBM DOS Reference Manual for details on the CONFIG.SYS file. Q. How do I change the colors of the editor and menus in TC? A. The utility TCINST.EXE allows you to customize your colors. Q. How do I get a listing of my source code to my printer? A. From within the Turbo C editor hit <Ctrl><K><P>. This will print a marked block to the printer. If no block is marked this key sequence will print the entire file in your editor. Q. When I Make, Run, or Trace a program Turbo C sometimes goes through the compile and link process even when the object files are up-to-date. A. Turbo C's MAKE logic works solely on a file's date and time stamp. If one of your source files is marked with a date that's sometime in the future, the object files that are created from it will always be older than the source file, and Turbo C will always try to rebuild the file. You can fix this by using TOUCH.COM to set the file to the current date and time. You should also make sure that your system's date and time are always properly set. C o m m a n d - L i n e C o m p i l e r --------------------------------------------------------------------- - Q. Why is Turbo C not able to find any of my #include files? A. The compiler searches for include files in the Turbo C Include Directories. This option is specified by the -I switch. The INSTALL program initially writes a configuration file (TURBOC.CFG) that sets this to the directory where it copied all the Turbo C *.h files
Q. Why do i get the messag Linker Error: Unable to open input file COx. OBJ A. The linker searches for Turbo C start-up and library files in the Turbo C Library Directories. This option is specified by the -L switch. If you allow tcc to invoke the linker it will search the directories in the configuration file (TURBoC. CFG) written by the INSTALL program. If you run tLINK, the configuration file is not read Q. Why does the linker tell me that all the graphics library routines are undefined? A. TCC will not search the graphics library unless you tell it to You should specify the graphics library on the command line. For example, to compi le bg idemo, type TCC BGIDEMO C GRAPHICS. LIB<Enter> e r a I/0 Q. The '\n' in cprintfo does not return the cursor to the beginning of the line. It only moves the cursor down one line. A. cprintf( no longer interprets,\n' as a Carriage Return/ Line Feed combination. The\n only outputs a Line Feed. To force the cursor to the beginning of the line, manually insert a Carriage Return cprintf (\n\r) Q. How do i print to the printer from a turbo c program? A. Turbo C uses a File pointer (stdprn) defined in the STDIO. H file. You do not need to open stdprn before using it #include <stdio. h> main( fprintf(stdprn,"Hello, world\n") Note that if your printer is line-buffered, the output i
Q. Why do I get the message: Linker Error: Unable to open input file 'C0x.OBJ' A. The linker searches for Turbo C start-up and library files in the Turbo C Library Directories. This option is specified by the -L switch. If you allow TCC to invoke the linker, it will search the directories in the configuration file (TURBOC.CFG) written by the INSTALL program. If you run TLINK, the configuration file is not read. Q. Why does the linker tell me that all the graphics library routines are undefined? A. TCC will not search the graphics library unless you tell it to. You should specify the graphics library on the command line. For example, to compile BGIDEMO, type TCC BGIDEMO.C GRAPHICS.LIB<Enter> G e n e r a l I / O --------------------------------------------------------------------- - Q. The '\n' in cprintf() does not return the cursor to the beginning of the line. It only moves the cursor down one line. A. cprintf() no longer interprets '\n' as a Carriage Return/ Line Feed combination. The '\n' only outputs a Line Feed. To force the cursor to the beginning of the line, manually insert a Carriage Return: cprintf("\n\r"); Q. How do I print to the printer from a Turbo C program? A. Turbo C uses a FILE pointer (stdprn) defined in the STDIO.H file. You do not need to open stdprn before using it: #include <stdio.h> main() { fprintf(stdprn, "Hello, world\n"); } Note that if your printer is line-buffered, the output is
flushed only after a\n is sent. Q. I am reading and writing binary files. My program is translating the Carriage Return(OxOD) and Line Feed(OxOA) characters. How do I prevent this from happening? A. Files opened in text mode will translate these characters for DOS. To read a file in binary mode, open it in binary mode Fo r examp #inc lude <stdio. h> main o FILE binary fp char buffer [100] binary fp fopen("MYFILE. BIN",rb") fread(buffer, sizeof (char), 100, binary fp) The default file mode is text Q. Why don't printf and puts print text in color? A. Use the console I/0 functions cprintfo and cputso for color output #include <conio. h> maino textcolor (BlUe) cprintf("im blue. Q. How do i print a long integer? A. Use the ld format long int I =70000L: printf(%ld", 1)
flushed only after a '\n' is sent. Q. I am reading and writing binary files. My program is translating the Carriage Return (0x0D) and Line Feed (0x0A) characters. How do I prevent this from happening? A. Files opened in text mode will translate these characters for DOS. To read a file in binary mode, open it in binary mode. For example #include <stdio.h> main() { FILE *binary_fp; char buffer[100]; binary_fp = fopen("MYFILE.BIN", "rb"); fread(buffer, sizeof(char), 100, binary_fp); : } The default file mode is text. Q. Why don't printf() and puts() print text in color? A. Use the console I/O functions cprintf() and cputs() for color output. #include <conio.h> main() { textcolor(BLUE); cprintf("I'm blue."); } Q. How do I print a long integer? A. Use the "%ld" format: long int l = 70000L; printf("%ld", l);