Watcom C Library : putc, putch, putchar, putenv, _putimage, _putimage_w, puts
Watcom C Reference/O - P - Q - R 2021. 9. 11. 18:46
Watcom C Library Reference : putc, putch, putchar, putenv, _putimage, _putimage_w, puts
putc
Synopsis : #include <stdio.h>
int putc( int c, FILE *fp );
Description : The putc function is equivalent to fputc, except it may be implemented as a macro. The putc function writes the character specified by the argument c to the output stream designated by fp.
Returns : The putc function returns the character written. If a write error occurs, the error indicator is set and putc returns EOF. When an error has occurred, errno contains a value indicating the type of error that has been detected.
See Also : fopen, fputc, fputchar, fputs, putchar, puts, ferror
Example :
#include <stdio.h>
void main( )
{
FILE *fp;
int c;
fp = fopen( "file", "r" );
if ( fp != NULL ) {
while( (c = fgetc( fp )) != EOF )
putc( c, stdout );
fclose( fp );
}
}
Classification : ANSI
Systems : All
putch
Synopsis : #include <conio.h>
int putch( int c );
Description : The putch function writes the character specified by the argument c to the console.
Returns : The putch function returns the character written.
See Also : getch, getche, kbhit, ungetch
Example :
#include <conio.h>
#include <stdio.h>
void main( )
{
FILE *fp;
int c;
fp = fopen( "file", "r" );
if ( fp != NULL ) {
while( (c = fgetc( fp )) != EOF )
putch ( c );
}
fclose( fp );
}
Classification : WATCOM
Systems : All
putchar
Synopsis : #include <stdio.h>
int putchar( int c );
Description : The putchar function writes the character specified by the argument c to the output stream stdout.
The function is equivalent to fputc( c, stdout );
Returns : The putchar function returns the character written. If a write error occurs, the error indicator is set and putchar returns EOF. When an error has occurred, errno contains a value indicating the type of error that has been detected.
See Also : fputc, fputchar, fputs, putc
Example :
#include <stdio.h>
void main( )
{
FILE *fp;
int c;
fp = fopen( "file", "r" );
c = fgetc( fp );
while( c != EOF ) {
putchar( c );
c = fgetc( fp );
}
fclose( fp );
}
Classification : ANSI
Systems : All
putenv
Synopsis : #include <process.h>
int putenv( const char *env_name );
Description : The environment list consists of a number of environment names, each of which has a value associated with it. Entries can be added to the environment list with the DOS set command or with the putenv function.
All entries in the environment list can be displayed by using the DOS set command with no arguments. A program can obtain the value for an environment variable by using the getenv function.
When the value of env_name has the format
env_name=value
an environment name and its value is added to the environment list. When the value of env_name has the format
env_name=
the environment name and value is removed from the environment list.
The matching is case-insensitive; all lowercase letters are treated as if they were in upper case.
The space into which environment names and their values are placed is limited. Consequently, the putenv function can fail when there is insufficient space remaining to store an additional value.
NOTE : If the argument env_name is not a literal string, you should duplicate the string, since putenv does not copy the value; for example,
putenv( strdup( buffer ) );
To assign a string to a variable and place it in the environment list:
C>SET INCLUDE=C:\WATCOM\H
To see what variables are in the environment list, and their current assignments:
C>SET
COMSPEC=C:\COMMAND.COM
PATH=C:\;C:\WATCOM
INCLUDE=C:\WATCOM\H
C>
Returns : The putenv function returns zero when it is successfully executed and returns - 1 when it fails.
Errors : When an error has occurred, errno contains a value indicating the type of error that has been detected.
ENOMEM Not enough memory to allocate a new environment string.
See Also : clearenv, getenv, setenv
Example :
The following gets the string currently assigned to INCLUDE and displays it, assigns a new value to it, gets and displays it, and then removes the environment name and value.
#include <stdio.h>
#include <stdlib.h>
void main( )
{
char *path;
path = getenv ( "INCLUDE" );
if ( path != NULL )
printf( "INCLUDE=%s\n", path );
if( putenv ( "INCLUDE=mylib;yourlib" ) != 0 )
printf( "putenv failed" );
path = getenv( "INCLUDE" );
if ( path != NULL )
printf( "INCLUDE=%s\n", path );
if( putenv( "INCLUDE=" ) != 0 )
printf( "putenv failed" );
}
produces the following :
INCLUDE=C:\WATCOM\H
INCLUDE=mylib;yourlib
Classification : WATCOM
Systems : All
_putimage, _putimage_w
Synopsis : #include <graph.h>
void FAR putimage( short x, short y, char _HUGE *image, short mode );
void FAR putimage_w( double x, double y, char _HUGE *image, short mode );
Description : The _putimage functions display the screen image indicated by the argument image. The _putimage function uses the view coordinate system. The _putimage_w function uses the window coordinate system.
The image is displayed upon the screen with its top left corner located at the point with coordinates (x, y). The image was previously saved using the _getimage functions. The image is displayed in a rectangle whose size is the size of the rectangular image saved by the _getimage functions.
The image can be displayed in a number of ways, depending upon the value of the mode argument. This argument can have the following values:
Values | Meaning |
_GPSET | replace the rectangle on the screen by the saved image |
_GPRESET | replace the rectangle on the screen with the pixel values of the saved image inverted; this produces a negative image |
_GAND | produce a new image on the screen by ANDing together the pixel values from the screen with those from the saved image |
_GOR | produce a new image on the screen by ORing together the pixel values from the screen with those from the saved image |
_GXOR | produce a new image on the screen by exclusive ORing together the pixel values from the screen with those from the saved image: the original screen is restored by two successive calls to the _putimage function with this value, providing an efficient method to produce animated effects |
Returns : The _putimage functions do not return a value.
See Also : _getimage, _imagesize
Example :
#include <conio.h>
#include <graph.h>
#include <malloc.h>
main( )
{
char *buf;
int y;
_setvideomode( _VRES16COLOR );
_ellipse( _GFILLINTERIOR, 100, 100, 200, 200 );
buf = malloc( _imagesize( 100, 100, 201, 201 ) );
if( buf != NULL ) {
_getimage( 100, 100, 201, 201, buf );
_putimage( 260, 200, buf, _GPSET );
_putimage( 420, 100, buf, _GPSET );
for( y = 100; y < 300; ) {
_putimage( 420, y, buf, _GXOR );
y += 20;
_putimage( 420, y, buf, _GXOR );
}
free( buf );
}
getch( );
_setvideomode( _DEFAULTMODE );
}
Classification : PC Graphics
Systems : _putimage - DOS, QNX
_putimage_w - DOS, QNX
puts
Synopsis : #include <stdio.h>
int puts( const char *buf );
Description : The puts function writes the character string pointed to by buf to the output stream
designated by stdout, and appends a new-line character to the output. The terminating null character is not written.
Returns : The puts function returns a non-zero value if an error occurs; otherwise, it returns zero. When an error has occurred, errno contains a value indicating the type of error that has been detected
See Also : fputs, putc
Example :
#include <stdio.h>
void main( )
{
FILE *fp;
char buffer[80];
fp = freopen( "file", "r", stdin );
while( gets ( buffer ) != NULL ) {
puts ( buffer );
}
fclose( fp );
}
Classification : ANSI
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)