strtol — convert text to long
strtol reads a long integer from the beginning of text. Check endptr and errno to detect errors and any unconsumed suffix.
CKTIS / C
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
strtol reads a long integer from the beginning of text. Check endptr and errno to detect errors and any unconsumed suffix.
strtold from <stdlib.h> reads an initial number from text as long double. endptr lets you check where conversion stopped.
strtoll reads an initial signed integer as long long. endptr and errno let you check the conversion result.
A guide to converting text to unsigned long and checking the result. The example demonstrates range checking and rejection of an unconsumed suffix.
strtoull converts an initial string portion to unsigned long long; endptr detects missing conversion and remaining text.
The system function from <stdlib.h> passes text to the environment's command processor. A NULL argument only queries its availability.
The tan function from <math.h> computes the tangent of an angle in radians. It accepts double and returns double; its argument is not interpreted as degrees.
The tanh function from <math.h> computes the hyperbolic tangent of a double argument and returns a double result.
thrd_create starts func(arg) in a new thread and stores its identifier through thr. The call returns creation status, not the worker's result.
The thrd_current function from <threads.h> returns the calling thread's identifier as a value of type thrd_t.
thrd_detach from <threads.h> arranges thread-resource reclamation after termination. It neither waits for termination nor stops the thread.
The thrd_equal function from <threads.h> checks whether two thrd_t identifiers refer to the same thread. It returns zero or a nonzero value.
thrd_exit terminates the calling thread and sets its int result, which can be retrieved using thrd_join.
thrd_join blocks the calling thread until the specified thread terminates and optionally retrieves its int result. The operation status is separate from the thread result.
thrd_sleep suspends the calling thread for a requested interval. A signal can interrupt the wait, and scheduling can extend it.
The thrd_yield function from <threads.h> attempts to allow other threads to run. It does not guarantee a context switch, takes no arguments, and returns no value.
The time function from <time.h> returns an approximation of current calendar time as time_t; check for (time_t)(-1).
timespec_get stores time in struct timespec. Check its return value before reading the fields; nanosecond representation does not guarantee nanosecond resolution.
The C23 function timespec_getres queries the resolution of time supplied by timespec_get, rather than the current time.
tmpfile() creates a temporary binary file for reading and writing. It returns FILE * or NULL if file creation fails.
tmpnam generates a filename but neither reserves it nor creates a file. Learn about the L_tmpnam buffer, NULL results, and the race when opening the name later.
tolower from <ctype.h> maps an uppercase letter to lowercase using the locale. Its argument must fit unsigned char or equal EOF.
toupper from <ctype.h> returns a corresponding uppercase letter according to the current locale, or leaves the value unchanged.
The trunc function from <math.h> removes the fractional part of a double by rounding toward zero. Its result is still a double, not an integer type.