📄 helpme!.doc
字号:
A: Use ios::binary as the open mode for the file:
#include <fstream.h>
ifstream binfile;
binfile.open("myfile.bin", ios::binary);
Q: How can I get at the DOS file handle associated with my iostream?
A: Using a combination of member functions fd() and rdbuf() you can
get at the file handle.
#include <fstream.h>
#define fstrno(s) (((s).rdbuf())->fd())
ifstream test("test.txt");
cout << "handle is " << fstrno(test) << '\n';
I n t e g r a t e d E n v i r o n m e n t
----------------------------------------------------------------------
Q: Why doesn't my mouse work well with Turbo C++?
A: The most likely cause is that you are using an older mouse driver. You'll
need to get a newer version. Driver versions required for full
compatibility include:
Logitech driver 5.01+, Microsoft 7.04+, Genius 9.06+.
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 path. You can specify this path through the
Options|Directories menu. The INSTALL program initially sets this
path 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 path. You can specify this path through
the Options|Directories menu. The INSTALL program initially sets this
path to the directory where it copied the start-up and library files.
Also be sure that you installed the memory model that the linker
is looking for. The 'x' in the error message corresponds to the memory
model, e.g. 's' for small, 'l' for large, etc.
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.
Q. Why does the linker tell me that all the graphics library routines
are undefined?
A. The Options|Linker|Libraries|Graphics Library item must be set ON
if you are using any Turbo C++ graphics functions and have not
specified 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=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. Where is the TCINST.EXE utility I have used in previous versions
of the compiler?
A. The capabilities of TCINST have been incorporated into other areas
of the product and thus TCINST is no longer necessary. To remap
key bindings, use the Turbo Editor Macro Compiler (TEMC). Colors
can be changed from within the IDE under Options | Environment | Colors.
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. TOUCH.COM is documented in
the file UTIL.DOC.
Q. How come my old Turbo C project files don't work anymore?
A. Project files now contain much more information about a project now,
and hence are no longer stored in ASCII format. To create a project
file, select PROJECT from the main menu, and follow the menus. To
convert your old project files to the new format, use the supplied
utility file PRJCNVT.EXE (documented in UTIL.DOC).
Q. How can I convert my Turbo C 2.0 project files to the new
format?
A. There is a conversion utility in your Turbo C++ BIN directory
called PRJCNVT.EXE. This program will perform the conversion.
Q. How come my project file is automatically loaded when I start Turbo C++?
I want to work on a different program.
A. If there is only one project file in the current directory, Turbo C++
will load and use that one file. If there are no project files, or
if there are multiple project files, Turbo C++ does not automatically
load one. Go ahead and create a new project. To use a specific project
file you can specify the name of that project file on the command
line used to start Turbo C++. For example, 'tc farley.prj' would
start up TC++ and load the 'farley' project.
Q. My right mouse button appears to do nothing. Can I change this so it
will set breakpoints?
A. Yes, under the menu for Options|Environment|Mouse there is a
dialog box for the right mouse button. You can change it to set
breakpoints, or to do many other things.
Q. How can I find out where my "null pointer assignment" is occurring?
A. Set a watch on the following expressions:
*(char *)0,4m
(char *)4
Step through the program. When the values change, the just-executed line
is the one that is causing the problem.
Q. When I compile my program, I get the following error:
Error: C:\TC\INCLUDE\STDIO.H: Overlays only supported in
medium, large, and huge memory models
What is happening?
A. The Overlay Support option has been selected and does not work
in the tiny, small, or compact memory models. You can turn this option
off with:
Options | Compiler | Code Generation | Overlay Support
Q. When I try to load a new file after editing a file, the first
file remains on the screen. How do I close the first file?
A. Use Alt-F3 to close the current file. Also, use F6 to move
from one file to the next, if there is more than one file
open at a time.
Q. I'm doing a search and replace operation, and the editor prompts me for
each replacement. I've selected "Change All", but it still does it.
A. To disable the prompting, you must unselect the "Prompt on replace"
option on the left side of the dialog box.
Q. When I try to use the any of the pseudo registers, like _AX, I
get the error message "Undefined symbol '_AX' in function..."
when I compile. Why?
A. You are only allowed to use the pseudo registers in the Turbo
C++ and ANSI modes of the compiler. You can change this setting
in the Options | Compiler | Source menu.
Q. Since I don't have a mouse, can I still copy blocks of code
from one file to another?
A. Yes. You can mark the beginning and end of a block by moving
to the appropriate area and pressing Ctrl-K-B (mark beginning) and
Ctrl-K-K (mark end). You can then use the copy and paste commands
in the Edit menu.
Q: How do I stop all of the files I have ever edited from constantly
being open when I bring up Turbo C++?
A: By default, Turbo C++ saves what is called the desktop configuration.
This configuration is saved in a file with a .DSK extension. By deleting
any files of this type, then entering Options/Environment/Preferences
and removing the check from 'auto save desktop', you will begin with a
clean desktop each time you invoke Turbo C++.
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 path. You specify this path with the -I option. The INSTALL
program initially writes a configuration file (TURBOC.CFG) that
sets this path 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 path. You can specify this path with
the -L option. 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.
TLINK does use the configuration file TLINK.CFG, so you can specify
library paths in this file.
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>
Q. I run TCC.EXE and get the error message:
Fatal: <filename>.def (<line #>): syntax error
A. Check your DATA statement on line number # in <filename>.def for the
correct code (that is, DATA PRELOAD).
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() interprets '\n' as 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>
int main(void)
{
fprintf(stdprn, "Hello, printer!\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 (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>
int main(void)
{
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>
int main(void)
{
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);
Q. How do I print a long double?
A. Use the "%Lf" format.
long double ldbl = 1E500;
printf("%Lf", ldbl);
E x a m p l e P r o g r a m s
----------------------------------------------------------------------
Q. How do I compile the BGIDEMO program?
A. 1. Make sure that the following Turbo C++ files are in your
current directory:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -