Watcom C Library Reference : mktime, modf, movedata, _moveto, _moveto_w, _msize Functions, nosound

 

 

 

 

mktime

 

Synopsis : #include <time.h> 

              time_t mktime( struct tm *timeptr );


              struct tm {

                  int tm_sec;     /* seconds after the minute    -- [0,61]   */ 

                  int tm_min;     /* minutes after the hour       -- [0,59]   */

                  int tm_hour;    /* hours after midnight          -- [0,23]   */

                  int tm_mday;   /* day of the month            -- [1,31]   */ 

                  int tm_mon;    /* months since January       -- [0,11]   */

                  int tm_year;    /* years since 1900                         */

                  int tm_wday;   /* days since Sunday          -- [0,6]    */ 

                  int tm_yday;   /* days since January 1        -- [0,365] */

                  int tm_isdst;   /* Daylight Savings Time flag                */

 


Description : The mktime function converts the local time information in the structure pointed to by timeptr into a calendar time (Coordinated Universal Time) with the same encoding used by the time Function. The originalvalues of the fields tm_sec, tm_min, tm_hour, tm_mday, and tm_mon are not restricted to ranges described for struct tm.

 

If these fields are not in their proper ranges, they are adjusted so that they are in the proper ranges. Values for the fields tm_wday and tm_yday are computed after all the other fields have been adjusted.

If the original value of tm_isdst is negative, this field is computed also. Otherwise, a value of 0 is treated as "daylight savings time is not in effect" and a positive value is treated as "daylight savings time is in effect".


Whenever mktime is called, the tzset function is also called.

 

 

Returns : The mktime function returns the converted calendar time.

 

 

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

 


Example :

#include <stdio.h> 

#include <time.h>


static const char *week_day [ ] = {
    "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" 

};


void main( )

{
    struct tm new_year;


    new_year.tm_year = 2001 - 1900;

    new_year.tm_mon = 0;

    new_year.tm_mday = 1;

    new_year.tm_hour = 0;

    new_year.tm_min = 0;

    new_year.tm_sec = 0;

    new_year.tm_isdst = 0;

 

    mktime( &new_year );

    printf( "The next century begins on a %s\n", week_days[new_year.tm_wday] );

}

 


produces the following :
The next century begins on a Monday

 

Classification : ANSI
Systems : All

 

 

 

 

 

modf

 

Synopsis : #include <math.h> 

              double modf( double value, double *iptr );

 


Description : The modf function breaks the argument value into integral and fractional parts, each of which has the same sign as the argument. It stores the integral part as a double in the object pointed to by iptr.

 

 

Returns : The modf function returns the signed fractional part of value.

 

 

See Also : frexp, ldexp

 


Example :

#include <stdio.h> 

#include <math.h>


void main( )

{
    double     integral_value, fractional_part;


    fractional_part = modf ( 4.5, &integral_value );

    printf( "%f  %f\n", fractional_part, integral_value);

 

    fractional_part = modf ( -4.5, &integral_value );

    printf( "%f  %f\n", fractional_part, integral_value);

}

 


produces the following :
0.500000  4.000000 

-0.500000  -4.000000

 

Classification : ANSI
Systems : All

 

 

 

 

 

movedata

 

Synopsis : #include <string.h> 

              void movedata( unsigned int src_segment,
                                unsigned int src_offset,

                                unsigned int tgt_segment,

                                unsigned int tgt_offset,

                                size_t length );


Description : The movedata function copies length bytes from the far pointer calculated as (src_segment:src_offset) to a target location determined as a far pointer (tgt_segment:tgt_offset).


Overlapping data may not be correctly copied. When the source and target areas may overlap, copy the areas one character at a time.


The function is useful to move data when the near address(es) of the source and/or target areas are not known.

 

 

Returns : No value is returned.

 

 

See Also : FP_SEG, FP_OFF, memcpy, segread

 


Example :

#include <stdio.h> 

#include <string.h> 

#include <dos.h>


void main( )

{
    char     buffer[14] = {
               '*', 0x17, 'H', 0x17, 'e', 0x17, 'l', 0x17, 'l', 0x17, 'o', 0x17, '*', 0x17 };


    movedata ( FP_SEG( buffer ), FP_OFF( buffer ), 0xB800, 0x0720, 14 );

}

 

Classification : WATCOM
Systems : All

 

 

 

 

 

_moveto, _moveto_w

 

Synopsis : #include <graph.h> 

              struct xycoord _FAR _moveto( short x, short y );
              struct _wxycoord _FAR _moveto_w( double x, double y );

 


Description : The _moveto functions set the current output position for graphics. The _moveto function uses the view coordinate system. The _moveto_w function uses the window coordinate system.


The current output position is set to be the point at the coordinates (x, y). Nothing is drawn by the function. The _lineto function uses the current output position as the starting point when a line is drawn.


Note that the output position for graphics output differs from that for text output. The output position for text output can be set by use of the _settextposition function.

 

 

Returns : The _moveto functions return the previous value of the output position for graphics.

 

 

See Also : getcurrentposition, _lineto, _settextposition

 


Example :

#include <conio.h> 

#include <graph.h>


main( )

{
    _setvideomode( _VRES16COLOR );

    _moveto( 100, 100 );

    _lineto( 540, 100 );

    _lineto( 320, 380 );

    _lineto( 100, 100 );

 

    getch( );

    setvideomode( _DEFAULTMODE );

}

 

Classification : PC Graphics
Systems : _moveto - DOS, QNX 

             _moveto_w - DOS, QNX

 

 

 

 

 

_msize Functions

 

Synopsis : #include <malloc.h> 

              size_t _msize ( void *buffer );

              size_t _bmsize( __segment seg, void __based (void) *buffer );

              size_t _fmsize ( void __far *buffer );

              size_t _nmsize ( void __near *buffer );

 


Description : The _msize functions return the size of the memory block pointed to by buffer that was allocated by a call to the appropriate version of the calloc, malloc, or realloc functions.


You must use the correct _msize function as listed below depending on which heap the memory block belongs to.

 Function  Heap
_msize  Depends on data model of the program
_bmsize  Based heap specified by seg value
_fmsize  Far heap (outside the default data segment)
_nmsize  Near heap (inside the default data segment)


In small data models (small and medium memory models), _msize maps to _nmsize. In large data models (compact, large and huge memory models), _msize maps to _fmsize.

 

 

Returns : The _msize functions return the size of the memory block pointed to by buffer.

 

 

See Also : calloc Functions, _expand Functions, free Functions, halloc, hfree, malloc Functions, realloc Functions, sbrk

 


Example :

#include <stdio.h> 

#include <malloc.h>


void main( )

{
    void     *buffer;


    buffer = malloc( 999 );

    printf( "Size of block is %u bytes\n", _msize ( buffer ) );

}

 


produces the following :
Size of block is 1000 bytes

 

Classification : WATCOM
Systems : _msize - All 

             _bmsize - DOS/16, Win/16, QNX/16, OS/2 1.x(all) 

             _fmsize - DOS/16, Win/16, QNX/16, OS/2 1.x(all) 

             _nmsize - DOS, Win, QNX, OS/2 1.x, OS/2 1.x(MT), OS/2 2.x, NT

 

 

 

 

 

 

nosound

 

Synopsis : #include <i86.h> 

              void nosound ( void );

 


Description : The nosound function turns off the PC's speaker.

 

 

Returns : The nosound function has no return value.

 

 

See Also : delay, sound

 


Example :

#include <i86.h>


void main( )

{
    sound( 200 );

    delay( 500 );     /* delay for 1/2 second */

    nosound( );
}

 

Classification : Intel
Systems : DOS, Win, QNX

 

 

 

 

 

 

 

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 전화카드
,