'왓콤C'에 해당되는 글 20건

  1. 2021.06.19 Watcom C Library Reference : cscanf, ctime, _ctime, cwait

 

 

Watcom C Library Reference : cscanf, ctime, _ctime, cwait

 

 

 

 

cscanf

 

Synopsis : #include <conio.h> 

              int cscanf( const char *format, ... );

Description : The cscanf function scans input from the console under control of the argument format.

Following the format string is a list of addresses to receive values. The cscanf function uses the function getche to read characters from the console. The format string is described under the description of the scanf function.

 

 

Returns : The cscanf function returns EOF when the scanning is terminated by reaching the end of the input stream. Otherwise, the number of input arguments for which values were successfully scanned and stored is returned. When a file input error occurs, the errno global variable may be set.

 

 

See Also : fscanf, scanf, sscanf, vcscanf, vfscanf, vscanf, vsscanf



Example : To scan a date in the form "Saturday April 18 1987":

#include <conio.h>


void main( )

{
    int day, year;

    char weekday[10], month[12];

   

    cscanf( "%s %s %d %d", weekday, month, &day, &year ); 

    cprintf( "\n%s, %s %d, %d\n", weekday, month, day, year );

}

 

Classification : WATCOM
Systems : All

 

 

 

 

 

ctime Functions

 

Synopsis : #include <time.h> 

              char * ctime ( const time_t *timer );

              char *_ctime ( const time_t *timer, char *buf );

Description : The ctime functions convert the calendar time pointed to by timer to local time in the form
of a string. The ctime function is equivalent to
   asctime ( localtime ( timer ) )


The ctime functions convert the time into a string containing exactly 26 characters. This string has the form shown in the following example:
    Sat Mar 21 15:58:27 1987\n\0


All fields have a constant width. The new-line character '\n' and the null character '\0' occupy the last two positions of the string.


The ANSI function ctime places the result string in a static buffer that is re-used each time ctime or asctime is called. The non-ANSI function _ctime places the result string in the buffer pointed to by buf.

 

Whenever the ctime functions are called, the tzset function is also called.


The calendar time is usually obtained by using the time function. That time is Coordinated Universal Time (UTC) (formerly known as Greenwich Mean Time (GMT)).


The time set on the computer with the DOS time command and the DOS date command reflects the local time. The environment variable TZ is used to establish the time zone to which this local time applies. See the section The TZ Environment Variable for a discussion of how to set the time zone.

 

 

Returns : The ctime functions return the pointer to the string containing the local time.

 

 

See Also : asctime, clock, difftime, gmtime, localtime, mktime, strftime, time. tzset


Example :

#include <stdio.h> 

#include <time.h>


void main( )

{
    time_t time_of_day;

    auto char buf [26];


    time_of_day = time ( NULL );

    printf( "It is now : %s", _ctime ( &time_of_day, buf) );

}

 

produces the following :
It is now : Fri Dec 25 15:58:42 1987

 

Classification : ANSI, _ctime is not ANSI
Systems : ctime - All, _ctime - All

 

 

 

 

 

cwait

 

Synopsis : #include <process.h> 

              int cwait( int *status, int process_id, int action );

Description : The cwait function suspends the calling process until the specified child process terminates.


If status is not NULL, it points to a word that will be filled in with the termination status word and return code of the terminated child process.


If the child process terminated normally, then the low order byte of the status wor set to 0, and the high order byte will contain the low order byte of the return code that the child process passed to the DOSEXIT function. The DOSEXIT function is called whenever main returns, or exit or _exit are explicity called.

 

If the child process did not terminate normally, then the high order byte of the status word will be set to 0, and the low order byte will contain one of the following values:

 Value  Meaning
 1  Hard-error abort
 2  Trap operation
 3  SIGTERM signal not intercepted

 

The process_id argument specifies which child process to wait for. This value is returned by the call to the spawn function that started the child process.


The action argument specifies when the parent process resumes execution. The possible values are:

 Value  Meaning
 WAIT_CHILD  Wait until the specified child process has ended.
 WAIT_GRANDCHILD  Wait until the specified child process and all of the child processes of that child process have ended.

 

 


Returns : The cwait function returns the child's process id if the child process terminated normally. Otherwise, cwait returns -1 and sets errno to one of the following values:

 Constant  Meaning
 EINVAL  Invalid action code
 ECHILD  Invalid process id, or the child does not exist.
 EINTR  The child process terminated abnormally.

 


See Also : exit, _exit, spawn Functions, wait



Example :

#include <stdio.h> 

#include <process.h>


void main( )
{
    int process_id; 

    int status;

    process_id = spawn1( P_NOWAIT, "child. exe", "child", "parm", NULL); 

    cwait ( &status, process_id, WAIT_CHILD );

}

 

Classification : OS/2
Systems : OS/2 1.x(all), OS/2 2.x

 

 

 

 

 

 

 

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)

 

 

 

728x90
반응형
Posted by 전화카드
,