Function Name: tell
Function: obtains the current position of the file pointer.
Usage: long tell (int handle );
Program example:
# Include
# Include
# Include
# Include
Int main (void)
{
Int handle;
Char msg [] = "Hello world ";
If (handle = open ("TEST. $", O_CREAT | O_TEXT | O_APPEND) =-1)
{
Perror ("Error :");
Return 1;
}
Write (handle, msg, strlen (msg ));
Printf ("The file pointer is at byte % ld", tell (handle ));
Close (handle );
Return 0;
}
Function Name: textattr
Function: set text attributes
Usage: void textattr (int attribute );
Program example:
# Include
Int main (void)
{
Int I;
Clrscr ();
For (I = 0; I <9; I)
{
Textattr (I 1) <4 ));
Cprintf ("This is a test ");
}
Return 0;
}
Function Name: textbackground
Function: select a new text background color.
Usage: void textbackground (int color );
Program example:
# Include
Int main (void)
{
Int I, j;
Clrscr ();
For (I = 0; I <9; I)
{
For (j = 0; j <80; j)
Cprintf ("C ");
Cprintf ("");
Textcolor (I 1 );
Textbackground (I );
}
Return 0;
}
Function Name: textcolor
Function: select a new character color in text mode.
Usage: void textcolor (int color );
Program example:
# Include
Int main (void)
{
Int I;
For (I = 0; I <15; I)
{
Textcolor (I );
Cprintf ("Foreground Color ");
}
Return 0;
}
Function Name: textheight
Function Name: vfprintf
Skill: Send formatted output to first-class
Usage: int vfprintf (FILE * stream, char * format, va_list param );
Program example:
# Include
# Include
# Include
FILE * fp;
Int vfpf (char * fmt ,...)
{
Va_list argptr;
Int cnt;
Va_start (argptr, fmt );
Cnt = vfprintf (fp, fmt, argptr );
Va_end (argptr );
Return (cnt );
}
Int main (void)
{
Int inumber = 30;
Float fnumber = 90.0;
Char string [4] = "abc ";
Fp = tmpfile ();
If (fp = NULL)
{
Perror ("tmpfile () call ");
Exit (1 );
}
Vfpf ("% d % f % s", inumber, fnumber, string );
Rewind (fp );
Fscanf (fp, "% d % f % s", & inumber, & fnumber, string );
Printf ("% d % f % s", inumber, fnumber, string );
Fclose (fp );
Return 0;
}
Function Name: vfscanf
Function: format the input from the stream.
Usage: int vfscanf (FILE * stream, char * format, va_list param );
Program example:
# Include
# Include
# Include
FILE * fp;
Int vfsf (char * fmt ,...)
{
Va_list argptr;
Int cnt;
Va_start (argptr, fmt );
Cnt = vfscanf (fp, fmt, argptr );
Va_end (argptr );
Return (cnt );
}
Int main (void)
{
Int inumber = 30;
Float fnumber = 90.0;
Char string [4] = "abc ";
Fp = tmpfile ();
If (fp = NULL)
{
Perror ("tmpfile () call ");
Exit (1 );
}
Fprintf (fp, "% d % f % s", inumber, fnumber, string );
Rewind (fp );
Vfsf ("% d % f % s", & inumber, & fnumber, string );
Printf ("% d % f % s", inumber, fnumber, string );
Fclose (fp );
Return 0;
}
Function Name: vprintf
Function: Send formatted output to stdout.
Usage: int vprintf (char * format, va_list param );
Program example:
# Include
# Include
Int vpf (char * fmt ,...)
{
Va_list argptr;
Int cnt;
Va_start (argptr, format );
Cnt = vprintf (fmt, argptr );
Va_end (argptr );
Return (cnt );
}
Int main (void)
{
Int inumber = 30;
Float fnumber = 90.0;
Char * string = "abc ";
Vpf ("% d % f % s", inumber, fnumber, string );
Return 0;
}
Function Name: vscanf
Function: format the input from stdin.
Usage: int vscanf (char * format, va_list param );
Program example:
# Include
# Include
# Include
Int vscnf (char * fmt ,...)
{
Va_list argptr;
Int cnt;
Printf ("Enter an integer, a float, and a string (e.g. I, f, s ,)");
Va_start (argptr, fmt );
Cnt = vscanf (fmt, argptr );
Va_end (argptr );
Return (cnt );
}
Int main (void)
{
Int inumber;
Float fnumber;
Char string [80];
Vscnf ("% d, % f, % s", & inumber, & fnumber, string );
Printf ("% d % f % s", inumber, fnumber, string );
Return 0;
}
Function Name: vsprintf
Function: Send formatted output to the string
Usage: int vsprintf (char * string, char * format, va_list param );
Program example:
# Include
# Include
# Include
Char buffer [80];
Int vspf (char * fmt ,...)
{
Va_list argptr;
Int cnt;
Va_start (argptr, fmt );
Cnt = vsprintf (buffer, fmt, argptr );
Va_end (argptr );
Return (cnt );
}
Int main (void)
{
Int inumber = 30;
Float fnumber = 90.0;
Char string [4] = "abc ";
Vspf ("% d % f % s", inumber, fnumber, string );
Printf ("% s", buffer );
Return 0;
}
Function Name: vsscanf
Function: format the input from the stream.
Usage: int vsscanf (char * s, char * format, va_list param );
Program example:
# Include
# Include
# Include
Char buffer [80] = "30 90.0 abc ";
Int vssf (char * fmt ,...)
{
Va_list argptr;
Int cnt;
Fflush (stdin );
Va_start (argptr, fmt );
Cnt = vsscanf (buffer, fmt, argptr );
Va_end (argptr );
Return (cnt );
}
Int main (void)
{
Int inumber;
Float fnumber;
Char string [80];
Vssf ("% d % f % s", & inumber, & fnumber, string );
Printf ("% d % f % s", inumber, fnumber, string );
Return 0;
}
Function Name: wherex
Function: return the horizontal cursor position in the window.
Usage: int wherex (void );
Program example:
# Include
Int main (void)
{
Clrscr ();
Gotoxy (10, 10 );
Cprintf ("Current location is X: % d Y: % d", wherex (), wherey ());
Getch ();
Return 0;
}
Function Name: wherey
Function: return the Vertical cursor position in the window.
Usage: int wherey (void );
Program example:
# Include
Int main (void)
{
Clrscr ();
Gotoxy (10, 10 );
Cprintf ("Current location is X: % d Y: % d", wherex (), wherey ());
Getch ();
Return 0;
}
Function Name: window
Function: defines the active text mode window.
Usage: void window (int left, int top, int right, int bottom );
Program example:
# Include
Int main (void)
{
Window (10, 10, 40, 11 );
Textcolor (BLACK );
Textbackground (WHITE );
Cprintf ("This is a test ");
Return 0;
}
Function Name: write
Skill: write to a file
Usage: int write (int handel, void * buf, int nbyte );
Program example:
# Include
# Include
# Include
# Include
# Include
# Include
Int main (void)
{
Int handle;
Char string [40];
Int length, res;
/*
Create a file named "TEST. $" in the current directory and write
A string to it. If "TEST. $" already exists, it will be overwritten.
*/
If (handle = open ("TEST. $", O_WRONLY | O_CREAT | O_TRUNC,
S_IREAD | S_IWRITE) =-1)
{
Printf ("Error opening file .");
Exit (1 );
}
Strcpy (string, "Hello, world! ");
Length = strlen (string );
If (res = write (handle, string, length ))! = Length)
{
Printf ("Error writing to the file .");
Exit (1 );
}
Printf ("Wrote % d bytes to the file.", res );
Close (handle );
Return 0;
}
Struct xfcb {
Char xfcb_flag;/* Contains 0xff to indicate xfcb */
Char xfcb_resv [5];/* Reserved for DOS */
Char xfcb_attr;/* Search attribute */
Struct fcb xfcb_fcb;/* The standard fcb */
};
Function Name: textmode
Function: set the screen to text mode.
Usage: void textmode (int mode );
Program example:
# Include
Int main (void)
{
Textmode (BW40 );
Cprintf ("ABC ");
Getch ();
Textmode (C40 );
Cprintf ("ABC ");
Getch ();
Textmode (BW80 );
Cprintf ("ABC ");
Getch ();
Textmode (C80 );
Cprintf ("ABC ");
Getch ();
Textmode (MONO );
Cprintf ("ABC ");
Getch ();
Return 0;
}
Function Name: textwidth
Function: Return