JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
man pages section 3: Basic Library Functions
search filter icon
search icon

Document Information

Preface

Basic Library Functions

a64l(3C)

abort(3C)

abs(3C)

addsev(3C)

addseverity(3C)

alloca(3C)

alphasort(3C)

alphasort(3UCB)

ascftime(3C)

asctime(3C)

asctime_r(3C)

assert(3C)

atexit(3C)

atof(3C)

atoi(3C)

atol(3C)

atoll(3C)

atomic_add_16(3C)

atomic_add_16_nv(3C)

atomic_add_32(3C)

atomic_add_32_nv(3C)

atomic_add(3C)

atomic_add_64(3C)

atomic_add_64_nv(3C)

atomic_add_8(3C)

atomic_add_8_nv(3C)

atomic_add_char(3C)

atomic_add_char_nv(3C)

atomic_add_int(3C)

atomic_add_int_nv(3C)

atomic_add_long(3C)

atomic_add_long_nv(3C)

atomic_add_ptr(3C)

atomic_add_ptr_nv(3C)

atomic_add_short(3C)

atomic_add_short_nv(3C)

atomic_and_16(3C)

atomic_and_16_nv(3C)

atomic_and_32(3C)

atomic_and_32_nv(3C)

atomic_and(3C)

atomic_and_64(3C)

atomic_and_64_nv(3C)

atomic_and_8(3C)

atomic_and_8_nv(3C)

atomic_and_uchar(3C)

atomic_and_uchar_nv(3C)

atomic_and_uint(3C)

atomic_and_uint_nv(3C)

atomic_and_ulong(3C)

atomic_and_ulong_nv(3C)

atomic_and_ushort(3C)

atomic_and_ushort_nv(3C)

atomic_bits(3C)

atomic_cas_16(3C)

atomic_cas_32(3C)

atomic_cas(3C)

atomic_cas_64(3C)

atomic_cas_8(3C)

atomic_cas_ptr(3C)

atomic_cas_uchar(3C)

atomic_cas_uint(3C)

atomic_cas_ulong(3C)

atomic_cas_ushort(3C)

atomic_clear_long_excl(3C)

atomic_dec_16(3C)

atomic_dec_16_nv(3C)

atomic_dec_32(3C)

atomic_dec_32_nv(3C)

atomic_dec(3C)

atomic_dec_64(3C)

atomic_dec_64_nv(3C)

atomic_dec_8(3C)

atomic_dec_8_nv(3C)

atomic_dec_ptr(3C)

atomic_dec_ptr_nv(3C)

atomic_dec_uchar(3C)

atomic_dec_uchar_nv(3C)

atomic_dec_uint(3C)

atomic_dec_uint_nv(3C)

atomic_dec_ulong(3C)

atomic_dec_ulong_nv(3C)

atomic_dec_ushort(3C)

atomic_dec_ushort_nv(3C)

atomic_inc_16(3C)

atomic_inc_16_nv(3C)

atomic_inc_32(3C)

atomic_inc_32_nv(3C)

atomic_inc(3C)

atomic_inc_64(3C)

atomic_inc_64_nv(3C)

atomic_inc_8(3C)

atomic_inc_8_nv(3C)

atomic_inc_ptr(3C)

atomic_inc_ptr_nv(3C)

atomic_inc_uchar(3C)

atomic_inc_uchar_nv(3C)

atomic_inc_uint(3C)

atomic_inc_uint_nv(3C)

atomic_inc_ulong(3C)

atomic_inc_ulong_nv(3C)

atomic_inc_ushort(3C)

atomic_inc_ushort_nv(3C)

atomic_ops(3C)

atomic_or_16(3C)

atomic_or_16_nv(3C)

atomic_or_32(3C)

atomic_or_32_nv(3C)

atomic_or(3C)

atomic_or_64(3C)

atomic_or_64_nv(3C)

atomic_or_8(3C)

atomic_or_8_nv(3C)

atomic_or_uchar(3C)

atomic_or_uchar_nv(3C)

atomic_or_uint(3C)

atomic_or_uint_nv(3C)

atomic_or_ulong(3C)

atomic_or_ulong_nv(3C)

atomic_or_ushort(3C)

atomic_or_ushort_nv(3C)

atomic_set_long_excl(3C)

atomic_swap_16(3C)

atomic_swap_32(3C)

atomic_swap(3C)

atomic_swap_64(3C)

atomic_swap_8(3C)

atomic_swap_ptr(3C)

atomic_swap_uchar(3C)

atomic_swap_uint(3C)

atomic_swap_ulong(3C)

atomic_swap_ushort(3C)

attropen(3C)

basename(3C)

bcmp(3C)

bcopy(3C)

bindtextdomain(3C)

bind_textdomain_codeset(3C)

bsdmalloc(3MALLOC)

bsd_signal(3C)

bsearch(3C)

bstring(3C)

btowc(3C)

bzero(3C)

calloc(3C)

calloc(3MALLOC)

catclose(3C)

catgets(3C)

catopen(3C)

cfgetispeed(3C)

cfgetospeed(3C)

cfsetispeed(3C)

cfsetospeed(3C)

cftime(3C)

clearerr(3C)

clock(3C)

closedir(3C)

closefrom(3C)

closelog(3C)

cond_broadcast(3C)

cond_destroy(3C)

cond_init(3C)

cond_reltimedwait(3C)

cond_signal(3C)

cond_timedwait(3C)

cond_wait(3C)

confstr(3C)

crypt(3C)

crypt_genhash_impl(3C)

crypt_gensalt(3C)

crypt_gensalt_impl(3C)

cset(3C)

csetcol(3C)

csetlen(3C)

csetno(3C)

ctermid(3C)

ctermid_r(3C)

ctime(3C)

ctime_r(3C)

ctype(3C)

cuserid(3C)

dbm(3UCB)

dbm_clearerr(3C)

dbm_close(3C)

dbmclose(3UCB)

dbm_delete(3C)

dbm_error(3C)

dbm_fetch(3C)

dbm_firstkey(3C)

dbminit(3UCB)

dbm_nextkey(3C)

dbm_open(3C)

dbm_store(3C)

dcgettext(3C)

dcngettext(3C)

decimal_to_double(3C)

decimal_to_extended(3C)

decimal_to_floating(3C)

decimal_to_quadruple(3C)

decimal_to_single(3C)

delete(3UCB)

dgettext(3C)

difftime(3C)

directio(3C)

dirname(3C)

div(3C)

dladdr1(3C)

dladdr(3C)

dlclose(3C)

dldump(3C)

dlerror(3C)

dlinfo(3C)

dlmopen(3C)

dlopen(3C)

dlsym(3C)

dngettext(3C)

double_to_decimal(3C)

drand48(3C)

dup2(3C)

econvert(3C)

ecvt(3C)

_edata(3C)

edata(3C)

enable_extended_FILE_stdio(3C)

encrypt(3C)

_end(3C)

end(3C)

endgrent(3C)

endnetgrent(3C)

endpwent(3C)

endspent(3C)

endusershell(3C)

endutent(3C)

endutxent(3C)

erand48(3C)

errno(3C)

_etext(3C)

etext(3C)

euccol(3C)

euclen(3C)

eucscol(3C)

exit(3C)

_exithandle(3C)

extended_to_decimal(3C)

fattach(3C)

__fbufsize(3C)

fclose(3C)

fconvert(3C)

fcvt(3C)

FD_CLR(3C)

fdetach(3C)

FD_ISSET(3C)

fdopen(3C)

fdopendir(3C)

FD_SET(3C)

fdwalk(3C)

FD_ZERO(3C)

feof(3C)

ferror(3C)

fetch(3UCB)

fflush(3C)

ffs(3C)

fgetc(3C)

fgetgrent(3C)

fgetgrent_r(3C)

fgetpos(3C)

fgetpwent(3C)

fgetpwent_r(3C)

fgets(3C)

fgetspent(3C)

fgetspent_r(3C)

fgetwc(3C)

fgetws(3C)

fileno(3C)

file_to_decimal(3C)

finite(3C)

firstkey(3UCB)

__flbf(3C)

floating_to_decimal(3C)

flock(3UCB)

flockfile(3C)

_flushlbf(3C)

fmtmsg(3C)

fnmatch(3C)

fopen(3C)

fopen(3UCB)

fpclass(3C)

__fpending(3C)

fpgetmask(3C)

fpgetround(3C)

fpgetsticky(3C)

fprintf(3C)

fprintf(3UCB)

fpsetmask(3C)

fpsetround(3C)

fpsetsticky(3C)

__fpurge(3C)

fputc(3C)

fputs(3C)

fputwc(3C)

fputws(3C)

fread(3C)

__freadable(3C)

__freading(3C)

free(3C)

free(3MALLOC)

freopen(3C)

freopen(3UCB)

fscanf(3C)

fseek(3C)

fseeko(3C)

__fsetlocking(3C)

fsetpos(3C)

fsync(3C)

ftell(3C)

ftello(3C)

ftime(3C)

ftok(3C)

ftruncate(3C)

ftrylockfile(3C)

ftw(3C)

func_to_decimal(3C)

funlockfile(3C)

fwide(3C)

fwprintf(3C)

__fwritable(3C)

fwrite(3C)

__fwriting(3C)

fwscanf(3C)

gconvert(3C)

gcvt(3C)

getc(3C)

getchar(3C)

getchar_unlocked(3C)

getcpuid(3C)

getc_unlocked(3C)

getcwd(3C)

getdate(3C)

getdtablesize(3C)

getenv(3C)

getexecname(3C)

getextmntent(3C)

getgrent(3C)

getgrent_r(3C)

getgrgid(3C)

getgrgid_r(3C)

getgrnam(3C)

getgrnam_r(3C)

gethomelgroup(3C)

gethostid(3C)

gethostname(3C)

gethrtime(3C)

gethrvtime(3C)

getloadavg(3C)

getlogin(3C)

getlogin_r(3C)

getmntany(3C)

getmntent(3C)

getnetgrent(3C)

getnetgrent_r(3C)

getopt(3C)

getopt_clip(3C)

getopt_long(3C)

getopt_long_only(3C)

getpagesize(3C)

getpagesizes(3C)

getpass(3C)

getpassphrase(3C)

getpeerucred(3C)

getpriority(3C)

getpw(3C)

getpwent(3C)

getpwent_r(3C)

getpwnam(3C)

getpwnam_r(3C)

getpwuid(3C)

getpwuid_r(3C)

getrusage(3C)

gets(3C)

getspent(3C)

getspent_r(3C)

getspnam(3C)

getspnam_r(3C)

getsubopt(3C)

gettext(3C)

gettimeofday(3C)

gettimeofday(3UCB)

gettxt(3C)

getusershell(3C)

getutent(3C)

getutid(3C)

getutline(3C)

getutmp(3C)

getutmpx(3C)

getutxent(3C)

getutxid(3C)

getutxline(3C)

getvfsany(3C)

getvfsent(3C)

getvfsfile(3C)

getvfsspec(3C)

getw(3C)

getwc(3C)

getwchar(3C)

getwd(3C)

getwidth(3C)

getws(3C)

getzoneid(3C)

getzoneidbyname(3C)

getzonenamebyid(3C)

glob(3C)

globfree(3C)

gmtime(3C)

gmtime_r(3C)

grantpt(3C)

gsignal(3C)

hasmntopt(3C)

hcreate(3C)

hdestroy(3C)

hsearch(3C)

iconv(3C)

iconv_close(3C)

iconv_open(3C)

imaxabs(3C)

imaxdiv(3C)

index(3C)

initgroups(3C)

initstate(3C)

innetgr(3C)

insque(3C)

isaexec(3C)

isalnum(3C)

isalpha(3C)

isascii(3C)

isastream(3C)

isatty(3C)

isblank(3C)

iscntrl(3C)

isdigit(3C)

isenglish(3C)

isgraph(3C)

isideogram(3C)

islower(3C)

isnand(3C)

isnanf(3C)

isnumber(3C)

isphonogram(3C)

isprint(3C)

ispunct(3C)

isspace(3C)

isspecial(3C)

is_system_labeled(3C)

isupper(3C)

iswalnum(3C)

iswalpha(3C)

iswascii(3C)

iswblank(3C)

iswcntrl(3C)

iswctype(3C)

iswdigit(3C)

iswgraph(3C)

iswlower(3C)

iswprint(3C)

iswpunct(3C)

iswspace(3C)

iswupper(3C)

iswxdigit(3C)

isxdigit(3C)

jrand48(3C)

killpg(3C)

l64a(3C)

labs(3C)

lckpwdf(3C)

lcong48(3C)

ldiv(3C)

lfind(3C)

lfmt(3C)

llabs(3C)

lldiv(3C)

lltostr(3C)

localeconv(3C)

localtime(3C)

localtime_r(3C)

lockf(3C)

_longjmp(3C)

longjmp(3C)

_longjmp(3UCB)

longjmp(3UCB)

lrand48(3C)

lsearch(3C)

madvise(3C)

major(3C)

makecontext(3C)

makedev(3C)

mallinfo(3MALLOC)

malloc(3C)

malloc(3MALLOC)

mallocctl(3MALLOC)

mallopt(3MALLOC)

mapmalloc(3MALLOC)

mblen(3C)

mbrlen(3C)

mbrtowc(3C)

mbsinit(3C)

mbsrtowcs(3C)

mbstowcs(3C)

mbtowc(3C)

mctl(3UCB)

memalign(3C)

memalign(3MALLOC)

membar_consumer(3C)

membar_enter(3C)

membar_exit(3C)

membar_ops(3C)

membar_producer(3C)

memccpy(3C)

memchr(3C)

memcmp(3C)

memcpy(3C)

memmove(3C)

memory(3C)

memset(3C)

minor(3C)

mkfifo(3C)

mkstemp(3C)

mktemp(3C)

mktime(3C)

mlock(3C)

mlockall(3C)

monitor(3C)

mrand48(3C)

msync(3C)

mtmalloc(3MALLOC)

munlock(3C)

munlockall(3C)

mutex_consistent(3C)

mutex_destroy(3C)

mutex_init(3C)

mutex_lock(3C)

mutex_trylock(3C)

mutex_unlock(3C)

ndbm(3C)

nextkey(3UCB)

nftw(3C)

ngettext(3C)

nice(3UCB)

nlist(3UCB)

nl_langinfo(3C)

nrand48(3C)

offsetof(3C)

opendir(3C)

openlog(3C)

pclose(3C)

perror(3C)

pfmt(3C)

plock(3C)

popen(3C)

port_alert(3C)

port_associate(3C)

port_create(3C)

port_dissociate(3C)

port_get(3C)

port_getn(3C)

port_send(3C)

port_sendn(3C)

posix_openpt(3C)

posix_spawn(3C)

posix_spawnattr_destroy(3C)

posix_spawnattr_getflags(3C)

posix_spawnattr_getpgroup(3C)

posix_spawnattr_getschedparam(3C)

posix_spawnattr_getschedpolicy(3C)

posix_spawnattr_getsigdefault(3C)

posix_spawnattr_getsigmask(3C)

posix_spawnattr_init(3C)

posix_spawnattr_setflags(3C)

posix_spawnattr_setpgroup(3C)

posix_spawnattr_setschedparam(3C)

posix_spawnattr_setschedpolicy(3C)

posix_spawnattr_setsigdefault(3C)

posix_spawnattr_setsigmask(3C)

posix_spawn_file_actions_addclose(3C)

posix_spawn_file_actions_adddup2(3C)

posix_spawn_file_actions_addopen(3C)

posix_spawn_file_actions_destroy(3C)

posix_spawn_file_actions_init(3C)

posix_spawnp(3C)

printf(3C)

printf(3UCB)

printstack(3C)

priv_addset(3C)

priv_allocset(3C)

priv_copyset(3C)

priv_delset(3C)

priv_emptyset(3C)

priv_fillset(3C)

priv_freeset(3C)

priv_getbyname(3C)

priv_getbynum(3C)

priv_getsetbyname(3C)

priv_getsetbynum(3C)

priv_gettext(3C)

priv_ineffect(3C)

priv_intersect(3C)

priv_inverse(3C)

priv_isemptyset(3C)

priv_isequalset(3C)

priv_isfullset(3C)

priv_ismember(3C)

priv_issubset(3C)

priv_set(3C)

priv_set_to_str(3C)

priv_str_to_set(3C)

priv_union(3C)

pselect(3C)

pset_getloadavg(3C)

psiginfo(3C)

psignal(3C)

psignal(3UCB)

pthread_atfork(3C)

pthread_attr_destroy(3C)

pthread_attr_getdetachstate(3C)

pthread_attr_getguardsize(3C)

pthread_attr_getinheritsched(3C)

pthread_attr_getschedparam(3C)

pthread_attr_getschedpolicy(3C)

pthread_attr_getscope(3C)

pthread_attr_getstack(3C)

pthread_attr_getstackaddr(3C)

pthread_attr_getstacksize(3C)

pthread_attr_init(3C)

pthread_attr_setdetachstate(3C)

pthread_attr_setguardsize(3C)

pthread_attr_setinheritsched(3C)

pthread_attr_setschedparam(3C)

pthread_attr_setschedpolicy(3C)

pthread_attr_setscope(3C)

pthread_attr_setstack(3C)

pthread_attr_setstackaddr(3C)

pthread_attr_setstacksize(3C)

pthread_barrierattr_destroy(3C)

pthread_barrierattr_getpshared(3C)

pthread_barrierattr_init(3C)

pthread_barrierattr_setpshared(3C)

pthread_barrier_destroy(3C)

pthread_barrier_init(3C)

pthread_barrier_wait(3C)

pthread_cancel(3C)

pthread_cleanup_pop(3C)

pthread_cleanup_push(3C)

pthread_condattr_destroy(3C)

pthread_condattr_getclock(3C)

pthread_condattr_getpshared(3C)

pthread_condattr_init(3C)

pthread_condattr_setclock(3C)

pthread_condattr_setpshared(3C)

pthread_cond_broadcast(3C)

pthread_cond_destroy(3C)

pthread_cond_init(3C)

pthread_cond_reltimedwait_np(3C)

pthread_cond_signal(3C)

pthread_cond_timedwait(3C)

pthread_cond_wait(3C)

pthread_create(3C)

pthread_detach(3C)

pthread_equal(3C)

pthread_exit(3C)

pthread_getconcurrency(3C)

pthread_getschedparam(3C)

pthread_getspecific(3C)

pthread_join(3C)

pthread_key_create(3C)

pthread_key_delete(3C)

pthread_kill(3C)

pthread_mutexattr_destroy(3C)

pthread_mutexattr_getprioceiling(3C)

pthread_mutexattr_getprotocol(3C)

pthread_mutexattr_getpshared(3C)

pthread_mutexattr_getrobust_np(3C)

pthread_mutexattr_gettype(3C)

pthread_mutexattr_init(3C)

pthread_mutexattr_setprioceiling(3C)

pthread_mutexattr_setprotocol(3C)

pthread_mutexattr_setpshared(3C)

pthread_mutexattr_setrobust_np(3C)

pthread_mutexattr_settype(3C)

pthread_mutex_consistent_np(3C)

pthread_mutex_destroy(3C)

pthread_mutex_getprioceiling(3C)

pthread_mutex_init(3C)

pthread_mutex_lock(3C)

pthread_mutex_reltimedlock_np(3C)

pthread_mutex_setprioceiling(3C)

pthread_mutex_timedlock(3C)

pthread_mutex_trylock(3C)

pthread_mutex_unlock(3C)

pthread_once(3C)

pthread_rwlockattr_destroy(3C)

pthread_rwlockattr_getpshared(3C)

pthread_rwlockattr_init(3C)

pthread_rwlockattr_setpshared(3C)

pthread_rwlock_destroy(3C)

pthread_rwlock_init(3C)

pthread_rwlock_rdlock(3C)

pthread_rwlock_reltimedrdlock_np(3C)

pthread_rwlock_reltimedwrlock_np(3C)

pthread_rwlock_timedrdlock(3C)

pthread_rwlock_timedwrlock(3C)

pthread_rwlock_tryrdlock(3C)

pthread_rwlock_trywrlock(3C)

pthread_rwlock_unlock(3C)

pthread_rwlock_wrlock(3C)

pthread_self(3C)

pthread_setcancelstate(3C)

pthread_setcanceltype(3C)

pthread_setconcurrency(3C)

pthread_setschedparam(3C)

pthread_setschedprio(3C)

pthread_setspecific(3C)

pthread_sigmask(3C)

pthread_spin_destroy(3C)

pthread_spin_init(3C)

pthread_spin_lock(3C)

pthread_spin_trylock(3C)

pthread_spin_unlock(3C)

pthread_testcancel(3C)

ptrace(3C)

ptsname(3C)

putc(3C)

putchar(3C)

putchar_unlocked(3C)

putc_unlocked(3C)

putenv(3C)

putmntent(3C)

putpwent(3C)

puts(3C)

putspent(3C)

pututline(3C)

pututxline(3C)

putw(3C)

putwc(3C)

putwchar(3C)

putws(3C)

qeconvert(3C)

qfconvert(3C)

qgconvert(3C)

qsort(3C)

quadruple_to_decimal(3C)

raise(3C)

rand(3C)

rand(3UCB)

random(3C)

rand_r(3C)

rctlblk_get_enforced_value(3C)

rctlblk_get_firing_time(3C)

rctlblk_get_global_action(3C)

rctlblk_get_global_flags(3C)

rctlblk_get_local_action(3C)

rctlblk_get_local_flags(3C)

rctlblk_get_privilege(3C)

rctlblk_get_recipient_pid(3C)

rctlblk_get_value(3C)

rctlblk_set_local_action(3C)

rctlblk_set_local_flags(3C)

rctlblk_set_privilege(3C)

rctlblk_set_recipient_pid(3C)

rctlblk_set_value(3C)

rctlblk_size(3C)

rctl_walk(3C)

readdir(3C)

readdir(3UCB)

readdir_r(3C)

realloc(3C)

realloc(3MALLOC)

realpath(3C)

reboot(3C)

re_comp(3C)

re_exec(3C)

regcmp(3C)

regcomp(3C)

regerror(3C)

regex(3C)

regexec(3C)

regfree(3C)

remove(3C)

remque(3C)

resetmnttab(3C)

rewind(3C)

rewinddir(3C)

rindex(3C)

rwlock(3C)

rwlock_destroy(3C)

rwlock_init(3C)

rw_rdlock(3C)

rw_tryrdlock(3C)

rw_trywrlock(3C)

rw_unlock(3C)

rw_wrlock(3C)

scandir(3C)

scandir(3UCB)

scanf(3C)

schedctl_exit(3C)

schedctl_init(3C)

schedctl_lookup(3C)

schedctl_start(3C)

schedctl_stop(3C)

seconvert(3C)

seed48(3C)

seekdir(3C)

select(3C)

sema_destroy(3C)

sema_init(3C)

semaphore(3C)

sema_post(3C)

sema_trywait(3C)

sema_wait(3C)

setbuf(3C)

setbuffer(3C)

setcat(3C)

setenv(3C)

setgrent(3C)

sethostname(3C)

_setjmp(3C)

setjmp(3C)

_setjmp(3UCB)

setjmp(3UCB)

setkey(3C)

setlabel(3C)

setlinebuf(3C)

setlocale(3C)

setlogmask(3C)

setnetgrent(3C)

setpriority(3C)

setpwent(3C)

setspent(3C)

setstate(3C)

settimeofday(3C)

settimeofday(3UCB)

setusershell(3C)

setutent(3C)

setutxent(3C)

setvbuf(3C)

sfconvert(3C)

sgconvert(3C)

sig2str(3C)

sigaddset(3C)

sigblock(3UCB)

sigdelset(3C)

sigemptyset(3C)

sigfillset(3C)

sigfpe(3C)

sighold(3C)

sigignore(3C)

siginterrupt(3C)

siginterrupt(3UCB)

sigismember(3C)

siglongjmp(3C)

sigmask(3UCB)

signal(3C)

signal(3UCB)

sigpause(3C)

sigpause(3UCB)

sigrelse(3C)

sigset(3C)

sigsetjmp(3C)

sigsetmask(3UCB)

sigsetops(3C)

sigstack(3C)

sigstack(3UCB)

sigvec(3UCB)

single_to_decimal(3C)

sleep(3C)

sleep(3UCB)

snprintf(3C)

sprintf(3C)

sprintf(3UCB)

srand(3C)

srand(3UCB)

srand48(3C)

srandom(3C)

sscanf(3C)

ssignal(3C)

stack_getbounds(3C)

_stack_grow(3C)

stack_inbounds(3C)

stack_setbounds(3C)

stack_violation(3C)

stdio(3C)

store(3UCB)

str2sig(3C)

strcasecmp(3C)

strcat(3C)

strchr(3C)

strcmp(3C)

strcoll(3C)

strcpy(3C)

strcspn(3C)

strdup(3C)

strerror(3C)

strerror_r(3C)

strfmon(3C)

strftime(3C)

string(3C)

string_to_decimal(3C)

strlcat(3C)

strlcpy(3C)

strlen(3C)

strncasecmp(3C)

strncat(3C)

strncmp(3C)

strncpy(3C)

strpbrk(3C)

strptime(3C)

strrchr(3C)

strsignal(3C)

strspn(3C)

strstr(3C)

strtod(3C)

strtof(3C)

strtoimax(3C)

strtok(3C)

strtok_r(3C)

strtol(3C)

strtold(3C)

strtoll(3C)

strtoul(3C)

strtoull(3C)

strtoumax(3C)

strtows(3C)

strxfrm(3C)

swab(3C)

swapcontext(3C)

swprintf(3C)

swscanf(3C)

sync_instruction_memory(3C)

syscall(3UCB)

sysconf(3C)

syslog(3C)

sys_siglist(3UCB)

system(3C)

tcdrain(3C)

tcflow(3C)

tcflush(3C)

tcgetattr(3C)

tcgetpgrp(3C)

tcgetsid(3C)

tcsendbreak(3C)

tcsetattr(3C)

tcsetpgrp(3C)

tdelete(3C)

td_event_addset(3C_DB)

td_event_delset(3C_DB)

td_event_emptyset(3C_DB)

td_event_fillset(3C_DB)

td_eventisempty(3C_DB)

td_eventismember(3C_DB)

td_init(3C_DB)

td_log(3C_DB)

td_sync_get_info(3C_DB)

td_sync_get_stats(3C_DB)

td_sync_setstate(3C_DB)

td_sync_waiters(3C_DB)

td_ta_clear_event(3C_DB)

td_ta_delete(3C_DB)

td_ta_enable_stats(3C_DB)

td_ta_event_addr(3C_DB)

td_ta_event_getmsg(3C_DB)

td_ta_get_nthreads(3C_DB)

td_ta_get_ph(3C_DB)

td_ta_get_stats(3C_DB)

td_ta_map_addr2sync(3C_DB)

td_ta_map_id2thr(3C_DB)

td_ta_map_lwp2thr(3C_DB)

td_ta_new(3C_DB)

td_ta_reset_stats(3C_DB)

td_ta_setconcurrency(3C_DB)

td_ta_set_event(3C_DB)

td_ta_sync_iter(3C_DB)

td_ta_sync_tracking_enable(3C_DB)

td_ta_thr_iter(3C_DB)

td_ta_tsd_iter(3C_DB)

td_thr_clear_event(3C_DB)

td_thr_dbresume(3C_DB)

td_thr_dbsuspend(3C_DB)

td_thr_event_enable(3C_DB)

td_thr_event_getmsg(3C_DB)

td_thr_getfpregs(3C_DB)

td_thr_getgregs(3C_DB)

td_thr_get_info(3C_DB)

td_thr_getxregs(3C_DB)

td_thr_getxregsize(3C_DB)

td_thr_lockowner(3C_DB)

td_thr_set_event(3C_DB)

td_thr_setfpregs(3C_DB)

td_thr_setgregs(3C_DB)

td_thr_setprio(3C_DB)

td_thr_setsigpending(3C_DB)

td_thr_setxregs(3C_DB)

td_thr_sigsetmask(3C_DB)

td_thr_sleepinfo(3C_DB)

td_thr_tsd(3C_DB)

td_thr_validate(3C_DB)

tell(3C)

telldir(3C)

tempnam(3C)

termios(3C)

textdomain(3C)

tfind(3C)

thr_continue(3C)

thr_create(3C)

thr_exit(3C)

thr_getconcurrency(3C)

thr_getprio(3C)

thr_getspecific(3C)

thr_join(3C)

thr_keycreate(3C)

thr_kill(3C)

thr_main(3C)

thr_min_stack(3C)

thr_self(3C)

thr_setconcurrency(3C)

thr_setprio(3C)

thr_setspecific(3C)

thr_sigsetmask(3C)

thr_stksegment(3C)

thr_suspend(3C)

thr_yield(3C)

times(3UCB)

tmpfile(3C)

tmpnam(3C)

tmpnam_r(3C)

toascii(3C)

_tolower(3C)

tolower(3C)

_toupper(3C)

toupper(3C)

towctrans(3C)

towlower(3C)

towupper(3C)

truncate(3C)

tsearch(3C)

ttyname(3C)

ttyname_r(3C)

ttyslot(3C)

twalk(3C)

tzset(3C)

u8_strcmp(3C)

u8_textprep_str(3C)

u8_validate(3C)

ualarm(3C)

uconv_u16tou32(3C)

uconv_u16tou8(3C)

uconv_u32tou16(3C)

uconv_u32tou8(3C)

uconv_u8tou16(3C)

uconv_u8tou32(3C)

ucred_free(3C)

ucred_get(3C)

ucred_getegid(3C)

ucred_geteuid(3C)

ucred_getgroups(3C)

ucred_getlabel(3C)

ucred_getpflags(3C)

ucred_getpid(3C)

ucred_getprivset(3C)

ucred_getprojid(3C)

ucred_getrgid(3C)

ucred_getruid(3C)

ucred_getsgid(3C)

ucred_getsuid(3C)

ucred_getzoneid(3C)

ucred_size(3C)

ulckpwdf(3C)

ulltostr(3C)

umem_alloc(3MALLOC)

umem_cache_alloc(3MALLOC)

umem_cache_create(3MALLOC)

umem_cache_destroy(3MALLOC)

umem_cache_free(3MALLOC)

umem_debug(3MALLOC)

umem_free(3MALLOC)

umem_nofail_callback(3MALLOC)

umem_zalloc(3MALLOC)

ungetc(3C)

ungetwc(3C)

unlockpt(3C)

unordered(3C)

unsetenv(3C)

updwtmp(3C)

updwtmpx(3C)

usleep(3C)

utmpname(3C)

utmpxname(3C)

valloc(3C)

valloc(3MALLOC)

vfprintf(3C)

vfprintf(3UCB)

vfscanf(3C)

vfwprintf(3C)

vfwscanf(3C)

vlfmt(3C)

vpfmt(3C)

vprintf(3C)

vprintf(3UCB)

vscanf(3C)

vsnprintf(3C)

vsprintf(3C)

vsprintf(3UCB)

vsscanf(3C)

vswprintf(3C)

vswscanf(3C)

vsyslog(3C)

vwprintf(3C)

vwscanf(3C)

wait3(3C)

wait3(3UCB)

wait(3C)

wait(3UCB)

wait4(3C)

wait4(3UCB)

waitpid(3C)

waitpid(3UCB)

walkcontext(3C)

watchmalloc(3MALLOC)

watof(3C)

watoi(3C)

watol(3C)

watoll(3C)

wcrtomb(3C)

wcscat(3C)

wcschr(3C)

wcscmp(3C)

wcscoll(3C)

wcscpy(3C)

wcscspn(3C)

wcsetno(3C)

wcsftime(3C)

wcslen(3C)

wcsncat(3C)

wcsncmp(3C)

wcsncpy(3C)

wcspbrk(3C)

wcsrchr(3C)

wcsrtombs(3C)

wcsspn(3C)

wcsstr(3C)

wcstod(3C)

wcstof(3C)

wcstoimax(3C)

wcstok(3C)

wcstol(3C)

wcstold(3C)

wcstoll(3C)

wcstombs(3C)

wcstoul(3C)

wcstoull(3C)

wcstoumax(3C)

wcstring(3C)

wcswcs(3C)

wcswidth(3C)

wcsxfrm(3C)

wctob(3C)

wctomb(3C)

wctrans(3C)

wctype(3C)

wcwidth(3C)

WIFEXITED(3UCB)

WIFSIGNALED(3UCB)

WIFSTOPPED(3UCB)

windex(3C)

wmemchr(3C)

wmemcmp(3C)

wmemcpy(3C)

wmemmove(3C)

wmemset(3C)

wordexp(3C)

wordfree(3C)

wprintf(3C)

wrindex(3C)

wscanf(3C)

wscasecmp(3C)

wscat(3C)

wschr(3C)

wscmp(3C)

wscol(3C)

wscoll(3C)

wscpy(3C)

wscspn(3C)

wsdup(3C)

wslen(3C)

wsncasecmp(3C)

wsncat(3C)

wsncmp(3C)

wsncpy(3C)

wspbrk(3C)

wsprintf(3C)

wsrchr(3C)

wsscanf(3C)

wsspn(3C)

wstod(3C)

wstok(3C)

wstol(3C)

wstostr(3C)

wstring(3C)

wsxfrm(3C)

scanf

, fscanf

, sscanf

, vscanf

, vfscanf

, vsscanf

- convert formatted input

Synopsis

#include <stdio.h>

int scanf(const char *restrict format...);
int fscanf(FILE *restrict stream, const char *restrict format...);
int sscanf(const char *restrict s, const char *restrict format...);
#include <stdarg.h>
#include <stdio.h>

int vscanf(const char *format, va_list arg);
int vfscanf(FILE *stream,  const char *format, va_list arg);
int vsscanf(const char *s, const char *format, va_list arg);

Description

The scanf() function reads from the standard input stream stdin.

The fscanf() function reads from the named input stream.

The sscanf() function reads from the string s.

The vscanf(), vfscanf(), and vsscanf() functions are equivalent to the scanf(), fscanf(), and sscanf() functions, respectively, except that instead of being called with a variable number of arguments, they are called with an argument list as defined by the <stdarg.h> header . These functions do not invoke the va_end() macro. Applications using these functions should call va_end(ap) afterwards to clean up.

Each function reads bytes, interprets them according to a format, and stores the results in its arguments. Each expects, as arguments, a control string format described below, and a set of pointer arguments indicating where the converted input should be stored. The result is undefined if there are insufficient arguments for the format. If the format is exhausted while arguments remain, the excess arguments are evaluated but are otherwise ignored.

Conversions can be applied to the nth argument after the format in the argument list, rather than to the next unused argument. In this case, the conversion character % (see below) is replaced by the sequence %n$, where n is a decimal integer in the range [1, NL_ARGMAX]. This feature provides for the definition of format strings that select arguments in an order appropriate to specific languages. In format strings containing the %n$ form of conversion specifications, it is unspecified whether numbered arguments in the argument list can be referenced from the format string more than once.

The format can contain either form of a conversion specification, that is, % or %n$, but the two forms cannot normally be mixed within a single format string. The only exception to this is that %% or %* can be mixed with the %n$ form.

The scanf() function in all its forms allows for detection of a language-dependent radix character in the input string. The radix character is defined in the program's locale (category LC_NUMERIC). In the POSIX locale, or in a locale where the radix character is not defined, the radix character defaults to a period (.).

The format is a character string, beginning and ending in its initial shift state, if any, composed of zero or more directives. Each directive is composed of one of the following:

Conversion Specifications

Each conversion specification is introduced by the character % or the character sequence %n$, after which the following appear in sequence:

The scanf() functions execute each directive of the format in turn. If a directive fails, as detailed below, the function returns. Failures are described as input failures (due to the unavailability of input bytes) or matching failures (due to inappropriate input).

A directive composed of one or more white-space characters is executed by reading input until no more valid input can be read, or up to the first byte which is not a white-space character which remains unread.

A directive that is an ordinary character is executed as follows. The next byte is read from the input and compared with the byte that comprises the directive; if the comparison shows that they are not equivalent, the directive fails, and the differing and subsequent bytes remain unread.

A directive that is a conversion specification defines a set of matching input sequences, as described below for each conversion character. A conversion specification is executed in the following steps:

Input white-space characters (as specified by isspace(3C)) are skipped, unless the conversion specification includes a [, c, C, or n conversion character.

An item is read from the input unless the conversion specification includes an n conversion character. The length of the item read is limited to any specified maximum field width, which is interpreted in either characters or bytes depending on the conversion character. In Solaris default mode, the input item is defined as the longest sequence of input bytes that forms a matching sequence. In some cases, scanf() might need to read several extra characters beyond the end of the input item to find the end of a matching sequence. In C99/SUSv3 mode, the input item is defined as the longest sequence of input bytes that is, or is a prefix of, a matching sequence. With this definition, scanf() need only read at most one character beyond the end of the input item. Therefore, in C99/SUSv3 mode, some sequences that are acceptable to strtod(3C), strtol(3C), and similar functions are unacceptable to scanf(). In either mode, scanf() attempts to push back any excess bytes read using ungetc(3C). Assuming all such attempts succeed, the first byte, if any, after the input item remains unread. If the length of the input item is 0, the conversion fails. This condition is a matching failure unless end-of-file, an encoding error, or a read error prevented input from the stream, in which case it is an input failure.

Except in the case of a % conversion character, the input item (or, in the case of a %n conversion specification, the count of input bytes) is converted to a type appropriate to the conversion character. If the input item is not a matching sequence, the execution of the conversion specification fails; this condition is a matching failure. Unless assignment suppression was indicated by a *, the result of the conversion is placed in the object pointed to by the first argument following the format argument that has not already received a conversion result if the conversion specification is introduced by %, or in the nth argument if introduced by the character sequence %n$. If this object does not have an appropriate type, or if the result of the conversion cannot be represented in the space provided, the behavior is undefined.

Length Modifiers

The length modifiers and their meanings are:

hh

Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type pointer to signed char or unsigned char.

h

Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type pointer to short or unsigned short.

l (ell)

Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type pointer to long or unsigned long; that a following a, A, e, E, f, F, g, or G conversion specifier applies to an argument with type pointer to double; or that a following c, s, or [ conversion specifier applies to an argument with type pointer to wchar_t.

ll (ell-ell)

Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type pointer to long long or unsigned long long.

j

Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type pointer to intmax_t or uintmax_t.

z

Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type pointer to size_t or the corresponding signed integer type.

t

Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type pointer to ptrdiff_t or the corresponding unsigned type.

L

Specifies that a following a, A, e, E, f, F, g, or G conversion specifier applies to an argument with type pointer to long double.

If a length modifier appears with any conversion specifier other than as specified above, the behavior is undefined.

Conversion Characters

The following conversion characters are valid:

d

Matches an optionally signed decimal integer, whose format is the same as expected for the subject sequence of strtol(3C) with the value 10 for the base argument. In the absence of a size modifier, the corresponding argument must be a pointer to int.

i

Matches an optionally signed integer, whose format is the same as expected for the subject sequence of strtol() with 0 for the base argument. In the absence of a size modifier, the corresponding argument must be a pointer to int.

o

Matches an optionally signed octal integer, whose format is the same as expected for the subject sequence of strtoul(3C) with the value 8 for the base argument. In the absence of a size modifier, the corresponding argument must be a pointer to unsigned int.

u

Matches an optionally signed decimal integer, whose format is the same as expected for the subject sequence of strtoul() with the value 10 for the base argument. In the absence of a size modifier, the corresponding argument must be a pointer to unsigned int.

x

Matches an optionally signed hexadecimal integer, whose format is the same as expected for the subject sequence of strtoul() with the value 16 for the base argument. In the absence of a size modifier, the corresponding argument must be a pointer to unsigned int.

a,e,f,g

Matches an optionally signed floating-point number, infinity, or NaN, whose format is the same as expected for the subject sequence of strtod(3C). In the absence of a size modifier, the corresponding argument must be a pointer to float. The e, f, and g specifiers match hexadecimal floating point values only in C99/SUSv3 (see standards(5)) mode, but the a specifier always matches hexadecimal floating point values.

These conversion specifiers match any subject sequence accepted by strtod(3C), including the INF, INFINITY, NAN, and NAN(n-char-sequence) forms. The result of the conversion is the same as that of calling strtod() (or strtof() or strtold()) with the matching sequence, including the raising of floating point exceptions and the setting of errno to ERANGE, if applicable.

s

Matches a sequence of bytes that are not white-space characters. The corresponding argument must be a pointer to the initial byte of an array of char, signed char, or unsigned char large enough to accept the sequence and a terminating null character code, which will be added automatically.

If an l (ell) qualifier is present, the input is a sequence of characters that begins in the initial shift state. Each character is converted to a wide-character as if by a call to the mbrtowc(3C) function, with the conversion state described by an mbstate_t object initialized to zero before the first character is converted. The corresponding argument must be a pointer to an array of wchar_t large enough to accept the sequence and the terminating null wide-character, which will be added automatically.

[

Matches a non-empty sequence of characters from a set of expected characters (the scanset). The normal skip over white-space characters is suppressed in this case. The corresponding argument must be a pointer to the initial byte of an array of char, signed char, or unsigned char large enough to accept the sequence and a terminating null byte, which will be added automatically.

If an l (ell) qualifier is present, the input is a sequence of characters that begins in the initial shift state. Each character in the sequence is converted to a wide-character as if by a call to the mbrtowc() function, with the conversion state described by an mbstate_t object initialized to zero before the first character is converted. The corresponding argument must be a pointer to an array of wchar_t large enough to accept the sequence and the terminating null wide-character, which will be added automatically.

The conversion specification includes all subsequent characters in the format string up to and including the matching right square bracket (]). The characters between the square brackets (the scanlist) comprise the scanset, unless the character after the left square bracket is a circumflex (^), in which case the scanset contains all characters that do not appear in the scanlist between the circumflex and the right square bracket. If the conversion specification begins with [ ] or [^], the right square bracket is included in the scanlist and the next right square bracket is the matching right square bracket that ends the conversion specification; otherwise the first right square bracket is the one that ends the conversion specification. If a is in the scanlist and is not the first character, nor the second where the first character is a ^, nor the last character, it indicates a range of characters to be matched.

c

Matches a sequence of characters of the number specified by the field width (1 if no field width is present in the conversion specification). The corresponding argument must be a pointer to the initial byte of an array of char, signed char, or unsigned char large enough to accept the sequence. No null byte is added. The normal skip over white-space characters is suppressed in this case.

If an l (ell) qualifier is present, the input is a sequence of characters that begins in the initial shift state. Each character in the sequence is converted to a wide-character as if by a call to the mbrtowc() function, with the conversion state described by an mbstate_t object initialized to zero before the first character is converted. The corresponding argument must be a pointer to an array of wchar_t large enough to accept the resulting sequence of wide-characters. No null wide-character is added.

p

Matches the set of sequences that is the same as the set of sequences that is produced by the %p conversion of the corresponding printf(3C) functions. The corresponding argument must be a pointer to a pointer to void. If the input item is a value converted earlier during the same program execution, the pointer that results will compare equal to that value; otherwise the behavior of the %p conversion is undefined.

n

No input is consumed. The corresponding argument must be a pointer to the integer into which is to be written the number of bytes read from the input so far by this call to the scanf() functions. Execution of a %n conversion specification does not increment the assignment count returned at the completion of execution of the function.

C

Same as lc.

S

Same as ls.

%

Matches a single %; no conversion or assignment occurs. The complete conversion specification must be %%.

If a conversion specification is invalid, the behavior is undefined.

The conversion characters A, E, F, G, and X are also valid and behave the same as, respectively, a, e, f, g, and x.

If end-of-file is encountered during input, conversion is terminated. If end-of-file occurs before any bytes matching the current conversion specification (except for %n) have been read (other than leading white-space characters, where permitted), execution of the current conversion specification terminates with an input failure. Otherwise, unless execution of the current conversion specification is terminated with a matching failure, execution of the following conversion specification (if any) is terminated with an input failure.

Reaching the end of the string in sscanf() is equivalent to encountering end-of-file for fscanf().

If conversion terminates on a conflicting input, the offending input is left unread in the input. Any trailing white space (including newline characters) is left unread unless matched by a conversion specification. The success of literal matches and suppressed assignments is only directly determinable via the %n conversion specification.

The fscanf() and scanf() functions may mark the st_atime field of the file associated with stream for update. The st_atime field will be marked for update by the first successful execution of fgetc(3C), fgets(3C), fread(3C), fscanf( ), getc(3C), getchar(3C), gets(3C), or scanf() using stream that returns data not supplied by a prior call to ungetc(3C).

Return Values

Upon successful completion, these functions return the number of successfully matched and assigned input items; this number can be 0 in the event of an early matching failure. If the input ends before the first matching failure or conversion, EOF is returned. If a read error occurs the error indicator for the stream is set, EOF is returned, and errno is set to indicate the error.

Errors

For the conditions under which the scanf() functions will fail and may fail, refer to fgetc(3C) or fgetwc(3C).

In addition, fscanf() may fail if:

EILSEQ

Input byte sequence does not form a valid character.

EINVAL

There are insufficient arguments.

Usage

If the application calling the scanf() functions has any objects of type wint_t or wchar_t, it must also include the header <wchar.h> to have these objects defined.

Examples

Example 1 The call:

int i, n; float x; char name[50];
n = scanf("%d%f%s", &i, &x, name)

with the input line:

25 54.32E–1 Hamster

will assign to n the value 3, to i the value 25, to x the value 5.432, and name will contain the string Hamster.

Example 2 The call:

int i; float x; char name[50];
(void) scanf("%2d%f%*d %[0123456789]", &i, &x, name);

with input:

56789 0123 56a72

will assign 56 to i, 789.0 to x, skip 0123, and place the string 56\0 in name. The next call to getchar(3C) will return the character a.

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
CSI
Enabled
Interface Stability
Standard
MT-Level
MT-Safe

See Also

fgetc(3C), fgets(3C), fgetwc(3C), fread(3C), isspace(3C), printf(3C), setlocale(3C), strtod(3C), strtol(3C), strtoul(3C), wcrtomb(3C), ungetc(3C), attributes(5), standards(5)