Watcom C Library : getc, getch, getchar, getche, _getcliprgn, getcmd
Watcom C Reference/G - H - I 2021. 6. 28. 17:44
Watcom C Library Reference : getc, getch, getchar, getche, _getcliprgn, getcmd
getc
Synopsis : #include <stdio.h>
int getc( FILE *fp );
Description : The getc function gets the next character from the file designated by fp. The character is returned as an int value. The getc function is equivalent to fgetc, except that it may be implemented as a macro.
Returns : The getc function returns the next character from the input stream pointed to by fp. If the stream is at end-of-file, the end-of-file indicator is set and getc returns EOF. If a read error occurs, the error indicator is set and getc returns EOF. When an error has oce errno contains a value indicating the type of error that has been detected.
See Also : fgetc, fgetchar, fgets, fopen, getchar, gets, ungetc
Example :
#include <stdio.h>
void main( )
{
FILE *fp;
int c;
fp = fopen( "file", "r" );
if( fp != NULL ) {
while( (c = getc( fp )) != EOF )
putchar( c );
fclose( fp );
}
}
Classification : ANSI
Systems : All
getch
Synopsis : #include <conio.h>
int getch( void );
Description : The getch function obtains the next available keystroke from the console. Nothing is echoed on the screen (the function getche will echo the keystroke, if possible). When no keystroke is available, the function waits until a key is depressed. The kbhit function can be used to determine if a keystroke is available.
Returns : A value of EOF is returned when an error is detected; otherwise the getch function returns the value of the keystroke (or character).
When the keystroke represents an extended function key (for example, a function key, a cursor-movement key or the ALT key with a letter or a digit), zero is returned and the next call to getch returns a value for the extended function.
See Also : getche, kbhit, putch, ungetch
Example :
#include <stdio.h>
#include <conio.h>
void main( )
{
int c;
printf( "Press any key\n" );
c = getch( );
printf( "You pressed %c (%d)\n", c, c);
}
Classification : WATCOM
Systems : All
getchar
Synopsis : #include <stdio.h>
int getchar( void );
Description : The getchar function is equivalent to getc with the argument stdin.
Returns : The getchar function returns the next character from the input stream pointed to by stdin. If the stream is at end-of-file, the end-of-file indicator is set and getchar returns EOF. If a read error occurs, the error indicator is set and getchar returns EOF. When an error has occurred, errno contains a value indicating the type of error that has been detected.
See Also : fgetc, fgetchar, getc
Example :
#include <stdio.h>
void main( )
{
FILE *fp;
int c;
fp = freopen( "file", "r", stdin );
while( (c = getchar( )) != EOF )
putchar( c );
fclose( fp );
}
Classification : ANSI
Systems : All
getche
Synopsis : #include <conio.h>
int getche( void );
Description : he getche function obtains the next available keystroke from the console. The function will wait until a keystroke is available. That character is echoed on the screen at the position of the cursor (use getch when it is not desired to echo the keystroke).
The kbhit function can be used to determine if a keystroke is available.
Returns : A value of EOF is returned when an error is detected; otherwise, the getche function returns the value of the keystroke (or character).
When the keystroke represents an extended function key (for example, a function key, a cursor-movement key or the ALT key with a letter or a digit), zero is returned and the next call to getche returns a value for the extended function.
See Also : getch, kbhit, putch, ungetch
Example :
#include <stdio.h>
#include <conio.h>
void main( )
{
int c;
printf( "Press any key\n" );
c = getche( );
printf( "You pressed %c (%d)\n", c, c);
}
Classification : WATCOM
Systems : All
_getcliprgn
Synopsis : #include <graph.h>
void _FAR _getcliprgn ( short _FAR *x1, short _FAR *y1,
short _FAR *x2, short _FAR *y2 );
Description : The _getcliprgn function returns the location of the current clipping region. A clipping region is defined with the _setcliprgn or _setviewport functions. By default, the clipping region is the entire screen.
The current clipping region is a rectangular area of the screen to which graphics output is restricted. The top left corner of the clipping region is placed in the arguments (x1, y1). The bottom right corner of the clipping region is placed in (x2, y2).
Returns : The _getcliprgn function returns the location of the current clipping region.
See Also : _setcliprgn, _setviewport
Example :
#include <conio.h>
#include <graph.h>
main( )
{
short x1, y1, x2, y2;
_setvideomode ( _VRES16COLOR );
_getcliprgn( &x1, &y1, &x2, &y2 );
_setcliprgn ( 130, 100, 510, 380 );
_ellipse( _GBORDER, 120, 90, 520, 390 );
getch( );
_setcliprgn( x1, y1, x2, y2);
_setvideomode ( _DEFAULTMODE );
}
Classification : PC Graphics
Systems : DOS, QNX
getcmd
Synopsis : #include <process.h>
char *getcmd( char *cmd_line );
Description : The getcmd function causes the command line information, with the program name removed, to be copied to cmd_line. The information is terminated with a '\0' character. This provides a method of obtaining the original parameters to a program unchanged (with the white space intact).
This information can also be obtained by examining the vector of program parameters passed to the main function in the program.
Returns : The address of the target cmd_line is returned.
See Also : abort, atexit, _bgetcmd, exec Functions, exit, _exit, getenv, main, onexit, putenv, spawn Functions, system
Example :
Suppose a program were invoked with the command line
myprog arg-1 ( my stuff ) here
where that program contains
#include <stdio.h>
#include <process.h>
void main( )
{
char cmds[128];
printf( "%s\n", getcmd( cmds ) );
}
produces the following :
arg-1 ( my stuff ) here
Classification : WATCOM
Systems : All
This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).
WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)