C language library function (W class)

xiaoxiao2021-03-06  41

Function name: Wherex

Function: Return to the horizontal cursor position in the window

Usage: int WHEREX (Void);

Example:

#include

Int main (void)

{

CLRSCR ();

gotoxy (10, 10);

CPRINTF ("Current Location IS X:% D Y:% D / R / N", wherex (), wherey ());

Getch ();

Return 0;

}

Function name: Wherey

Function: Return to the vertical cursor position in the window

Usage: int wherey (void);

Example:

#include

Int main (void)

{

CLRSCR ();

gotoxy (10, 10);

CPRINTF ("Current Location IS X:% D Y:% D / R / N", wherex (), wherey ());

Getch ();

Return 0;

}

Function name: Window

Function: Define the event text mode window

Usage: void window (int LEFT, INT TOP, INT RIGHT, INT BOTTOM);

Example:

#include

Int main (void)

{

WINDOW (10, 10, 40, 11);

TextColor (Black);

Textbackground (White);

CPRINTF ("this is a test / r / n");

Return 0;

}

Function name: Write

Function: Write to a file

Usage: int WRITE (INT Handel, Void * BUF, INT NBYTE);

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 (("Test. $$$", O_Wronly | O_CREAT | O_TRUNC,

S_iread | s_iwrite)) == -1)

{

Printf ("Error Opening File./N);

Exit (1);

}

STRCPY (String, "Hello, World! / N");

Length = Strlen (String);

IF ((res = write (handle, string, length))! = length)

{

Printf ("Error Writing to The File./N);

Exit (1);

}

Printf ("Wrote% D Bytes to the file./n", res);

Close (Handle);

Return 0;

}

转载请注明原文地址:https://www.9cbs.com/read-74425.html

New Post(0)