Friday, February 19, 2010

graphics library

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

Q. I run TCC.EXE and get the error message:

Fatal: .def (): syntax error

A. Check your DATA statement on line number # in .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

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

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.

No comments:

Post a Comment