Стандарт языка Си С99 TC (1113411), страница 62
Текст из файла (страница 62)
The strtok function saves a pointer to the followingcharacter, from which the next search for a token will start.5Each subsequent call, with a null pointer as the value of the first argument, startssearching from the saved pointer and behaves as described above.6The implementation shall behave as if no library function calls the strtok function.Returns7The strtok function returns a pointer to the first character of a token, or a null pointerif there is no token.8EXAMPLE#include <string.h>static char str[] = "?a???b,,,#c";char *t;tttt====strtok(str, "?");strtok(NULL, ",");strtok(NULL, "#,");strtok(NULL, "?");////////ttttpoints to the token "a"points to the token "??b"points to the token "c"is a null pointer7.21.6 Miscellaneous functions7.21.6.1 The memset functionSynopsis1#include <string.h>void *memset(void *s, int c, size_t n);Description2The memset function copies the value of c (converted to an unsigned char) intoeach of the first n characters of the object pointed to by s.Returns3The memset function returns the value of s.§7.21.6.1Library333ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.21.6.2 The strerror functionSynopsis1#include <string.h>char *strerror(int errnum);Description2The strerror function maps the number in errnum to a message string.
Typically,the values for errnum come from errno, but strerror shall map any value of typeint to a message.3The implementation shall behave as if no library function calls the strerror function.Returns4The strerror function returns a pointer to the string, the contents of which are localespecific. The array pointed to shall not be modified by the program, but may beoverwritten by a subsequent call to the strerror function.7.21.6.3 The strlen functionSynopsis1#include <string.h>size_t strlen(const char *s);Description2The strlen function computes the length of the string pointed to by s.Returns3The strlen function returns the number of characters that precede the terminating nullcharacter.334Library§7.21.6.3WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC37.22 Type-generic math <tgmath.h>1The header <tgmath.h> includes the headers <math.h> and <complex.h> anddefines several type-generic macros.2Of the <math.h> and <complex.h> functions without an f (float) or l (longdouble) suffix, several have one or more parameters whose corresponding real type isdouble.
For each such function, except modf, there is a corresponding type-genericmacro.272) The parameters whose corresponding real type is double in the functionsynopsis are generic parameters. Use of the macro invokes a function whosecorresponding real type and type domain are determined by the arguments for the genericparameters.273)3Use of the macro invokes a function whose generic parameters have the correspondingreal type determined as follows:— First, if any argument for generic parameters has type long double, the typedetermined is long double.— Otherwise, if any argument for generic parameters has type double or is of integertype, the type determined is double.— Otherwise, the type determined is float.4For each unsuffixed function in <math.h> for which there is a function in<complex.h> with the same name except for a c prefix, the corresponding typegeneric macro (for both functions) has the same name as the function in <math.h>.
Thecorresponding type-generic macro for fabs and cabs is fabs.272) Like other function-like macros in Standard libraries, each type-generic macro can be suppressed tomake available the corresponding ordinary function.273) If the type of the argument is not compatible with the type of the parameter for the selected function,the behavior is undefined.§7.22Library335ISO/IEC 9899:TC3<math.h>functionacosasinatanacoshasinhatanhcossintancoshsinhtanhexplogpowsqrtfabsCommittee Draft — Septermber 7, 2007<complex.h>functioncacoscasincatancacoshcasinhcatanhccoscsinctanccoshcsinhctanhcexpclogcpowcsqrtcabsWG14/N1256type-genericmacroacosasinatanacoshasinhatanhcossintancoshsinhtanhexplogpowsqrtfabsIf at least one argument for a generic parameter is complex, then use of the macro invokesa complex function; otherwise, use of the macro invokes a real function.5For each unsuffixed function in <math.h> without a c-prefixed counterpart in<complex.h> (except modf), the corresponding type-generic macro has the samename as the function.
These type-generic macros are:atan2cbrtceilcopysignerferfcexp2expm1fdimfloorfmafmaxfminfmodfrexphypotilogbldexplgammallrintllroundlog10log1plog2logblrintlroundnearbyintnextafternexttowardremainderremquorintroundscalbnscalblntgammatruncIf all arguments for generic parameters are real, then use of the macro invokes a realfunction; otherwise, use of the macro results in undefined behavior.6For each unsuffixed function in <complex.h> that is not a c-prefixed counterpart to afunction in <math.h>, the corresponding type-generic macro has the same name as thefunction.
These type-generic macros are:336Library§7.22WG14/N1256cargcimagCommittee Draft — Septermber 7, 2007conjcprojISO/IEC 9899:TC3crealUse of the macro with any real or complex argument invokes a complex function.7EXAMPLEWith the declarations#include <tgmath.h>int n;float f;double d;long double ld;float complex fc;double complex dc;long double complex ldc;functions invoked by use of type-generic macros are shown in the following table:macro useexp(n)acosh(f)sin(d)atan(ld)log(fc)sqrt(dc)pow(ldc, f)remainder(n, n)nextafter(d, f)nexttoward(f, ld)copysign(n, ld)ceil(fc)rint(dc)fmax(ldc, ld)carg(n)cproj(f)creal(d)cimag(ld)fabs(fc)carg(dc)cproj(ldc)§7.22invokesexp(n), the functionacoshf(f)sin(d), the functionatanl(ld)clogf(fc)csqrt(dc)cpowl(ldc, f)remainder(n, n), the functionnextafter(d, f), the functionnexttowardf(f, ld)copysignl(n, ld)undefined behaviorundefined behaviorundefined behaviorcarg(n), the functioncprojf(f)creal(d), the functioncimagl(ld)cabsf(fc)carg(dc), the functioncprojl(ldc)Library337ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.23 Date and time <time.h>7.23.1 Components of time1The header <time.h> defines two macros, and declares several types and functions formanipulating time.
Many functions deal with a calendar time that represents the currentdate (according to the Gregorian calendar) and time. Some functions deal with localtime, which is the calendar time expressed for some specific time zone, and with DaylightSaving Time, which is a temporary change in the algorithm for determining local time.The local time zone and Daylight Saving Time are implementation-defined.2The macros defined are NULL (described in 7.17); andCLOCKS_PER_SECwhich expands to an expression with type clock_t (described below) that is thenumber per second of the value returned by the clock function.3The types declared are size_t (described in 7.17);clock_tandtime_twhich are arithmetic types capable of representing times; andstruct tmwhich holds the components of a calendar time, called the broken-down time.4The range and precision of times representable in clock_t and time_t areimplementation-defined.
The tm structure shall contain at least the following members,in any order. The semantics of the members and their normal ranges are expressed in thecomments.274)intintintintintintintintinttm_sec;tm_min;tm_hour;tm_mday;tm_mon;tm_year;tm_wday;tm_yday;tm_isdst;//////////////////seconds after the minute — [0, 60]minutes after the hour — [0, 59]hours since midnight — [0, 23]day of the month — [1, 31]months since January — [0, 11]years since 1900days since Sunday — [0, 6]days since January 1 — [0, 365]Daylight Saving Time flag274) The range [0, 60] for tm_sec allows for a positive leap second.338Library§7.23.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3The value of tm_isdst is positive if Daylight Saving Time is in effect, zero if DaylightSaving Time is not in effect, and negative if the information is not available.7.23.2 Time manipulation functions7.23.2.1 The clock functionSynopsis1#include <time.h>clock_t clock(void);Description2The clock function determines the processor time used.Returns3The clock function returns the implementation’s best approximation to the processortime used by the program since the beginning of an implementation-defined era relatedonly to the program invocation.
To determine the time in seconds, the value returned bythe clock function should be divided by the value of the macro CLOCKS_PER_SEC. Ifthe processor time used is not available or its value cannot be represented, the functionreturns the value (clock_t)(-1).275)7.23.2.2 The difftime functionSynopsis1#include <time.h>double difftime(time_t time1, time_t time0);Description2The difftime function computes the difference between two calendar times: time1 time0.Returns3The difftime function returns the difference expressed in seconds as a double.275) In order to measure the time spent in a program, the clock function should be called at the start ofthe program and its return value subtracted from the value returned by subsequent calls.§7.23.2.2Library339ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.23.2.3 The mktime functionSynopsis1#include <time.h>time_t mktime(struct tm *timeptr);Description2The mktime function converts the broken-down time, expressed as local time, in thestructure pointed to by timeptr into a calendar time value with the same encoding asthat of the values returned by the time function.